Last active
December 4, 2024 09:23
-
-
Save Suhaib3100/57dc32dd6f9ef790c2ca568e741d56fb to your computer and use it in GitHub Desktop.
Example Event Logger
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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