Created
March 7, 2023 13:19
-
-
Save Priyanshu9898/63846e45fb489093550c0ce2e4690b69 to your computer and use it in GitHub Desktop.
Code for Logger file
This file contains 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 logging | |
import os | |
from datetime import datetime | |
LOG_FILE=f"{datetime.now().strftime('%m_%d_%Y_%H_%M_%S')}.log" | |
logs_path=os.path.join(os.getcwd(),"logs",LOG_FILE) | |
os.makedirs(logs_path,exist_ok=True) | |
LOG_FILE_PATH=os.path.join(logs_path,LOG_FILE) | |
logging.basicConfig( | |
filename=LOG_FILE_PATH, | |
format="[ %(asctime)s ] %(lineno)d %(name)s - %(levelname)s - %(message)s", | |
level=logging.INFO, | |
) | |
if __name__ == "__main__": | |
logging.info("Logging has started.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment