Add custom python logging lvlname -


i'm used using log levels using following standard logging methods:

logging.info('info message') logging.debug('debug message') 

and have formatter following

stream_formatter = logging.formatter('%(asctime)s - %(levelname)s - % - %(message)s') 

so log looks like:

2016-06-01 23:18:42,602 - info - info message 2016-06-01 23:18:42,700 - debug - debug message 

i want create new logging level follows:

logging.log(15, 'new level') 

how print like:

2016-06-01 23:18:42,800 - custom_level - new level 

found in documentation there public method in logging module: logging.addlevelname(lvl, levelname)

custom_level = 15 logging.addlevelname(custom_level, 'custom_level') 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo