Created
January 31, 2024 10:04
-
-
Save weimeng23/5f18947d17040a19e8d31a66136142f7 to your computer and use it in GitHub Desktop.
python useful 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
logger = logging.getLogger(__name__) | |
logger.setLevel(level=logging.DEBUG) | |
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') | |
formatter = logging.Formatter('%(asctime)s | %(levelname)s | %(filename)s | %(threadName)s | %(funcName)s | %(lineno)s | %(message)s') | |
fh = logging.FileHandler("log.txt") | |
fh.setLevel(logging.INFO) | |
fh.setFormatter(formatter) | |
logger.addHandler(fh) | |
ch = logging.StreamHandler() | |
ch.setLevel(logging.INFO) | |
ch.setFormatter(formatter) | |
logger.addHandler(ch) | |
logger.info('init SpeechEmotionRecognition class') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment