Python log wrapper
Project description
README
Table of Contents
Python log wrapper
Configuration
Configuration file example (toml format)
[log]
to_console = true
console_level = 'DEBUG'
to_file = true
file_level = ['INFO', 'WARNING', 'ERROR', 'CRITICAL']
format = '%(asctime)s | %(levelname)-8s | <%(threadName)s> %(module)s.%(funcName)s [%(lineno)d]: %(message)s'
to_console
: whether to output log to STDOUT, 'true' or 'false', use it during debugging, and close it during formal deploymentconsole_level
: console log level (string), optional values are 'DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'to_file
: whether to output log to file, 'true' or 'false'file_level
: file log level (list), fill in 'INFO', 'WARNING', 'ERROR', 'CRITICAL' according to the actual situationformat
: log format, '8' represents the string length, '-' represents left alignment (default right alignment)
Usage
from logwrapper import get_logger
log_conf = {
'to_console': True,
'console_level': 'DEBUG',
'to_file': True,
'file_level': ['WARNING', 'ERROR', 'CRITICAL'],
'format':
'''%(asctime)s | %(levelname)-8s | <%(threadName)s> '''
'''%(module)s.%(funcName)s [%(lineno)d]: %(message)s'''
}
def main():
"""docstring for main"""
logger = get_logger(logfolder='logs', config=log_conf)
logger.warning('Warning text')
logger.error('Error text')
logger.critical('Critical text')
if __name__ == "__main__":
main()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
logwrapper-0.1.3.tar.gz
(15.6 kB
view hashes)
Built Distribution
logwrapper-0.1.3-py3-none-any.whl
(15.9 kB
view hashes)
Close
Hashes for logwrapper-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f26d6746335cff9be62eb95f4685001412f6099bf54e03e5af6e97c8cefb1d3 |
|
MD5 | 6e162ae2fa212ece3eb057e33b4e9562 |
|
BLAKE2b-256 | ab50ebaee1a2cc75d4e6d65aac6df210084eaf1419fc21e381c59b27486f4d73 |