Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
from datetime import datetime # DO NOT CHANGE THIS IMPORT
from time import sleep


def main():
# write your code here
pass
def main() -> None:
"""
Create a log file every second with the current timestamp.
The file name follows the format 'app-H_M_S.log' and the content includes
the full date and time (YYYY-MM-DD HH:MM:SS).
"""
while True:
get_time = datetime.now()
ts_str = get_time.strftime("%Y-%m-%d %H:%M:%S")
file_name = f"app-{get_time.hour}_{get_time.minute}_{
get_time.second}.log"

with open(file_name, "w") as file:
file.write(ts_str)
print(ts_str, file_name)
sleep(1)


if __name__ == "__main__":
Expand Down
Loading