Skip to content

Instantly share code, notes, and snippets.

@Suhaib3100
Last active December 4, 2024 09:23
Show Gist options
  • Save Suhaib3100/57dc32dd6f9ef790c2ca568e741d56fb to your computer and use it in GitHub Desktop.
Save Suhaib3100/57dc32dd6f9ef790c2ca568e741d56fb to your computer and use it in GitHub Desktop.
Example Event Logger
import time
from datetime import datetime
# Log an event with the current timestamp
def log_event(event):
current_timestamp = time.time() # Get the timestamp
readable_time = datetime.fromtimestamp(current_timestamp).strftime("%Y-%m-%d %H:%M:%S")
print(f"[{readable_time}] Event: {event}")
# Example usage
log_event("User logged in")
time.sleep(2) # Simulate delay
log_event("File uploaded")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment