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.5.tar.gz
(15.6 kB
view details)
Built Distribution
File details
Details for the file logwrapper-0.1.5.tar.gz
.
File metadata
- Download URL: logwrapper-0.1.5.tar.gz
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f67d41337a20ee07eed951d149d6c9b5e757ca5b7d008779bd9f4a67f1df1dd6 |
|
MD5 | 8a90d1f0552752e4559a3a8106dedabc |
|
BLAKE2b-256 | ddc73fe93bbfbe9f39239ca503a45f99b884fd44a8a157ba6f59ce9ef151b15d |
File details
Details for the file logwrapper-0.1.5-py3-none-any.whl
.
File metadata
- Download URL: logwrapper-0.1.5-py3-none-any.whl
- Upload date:
- Size: 15.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c5519b171b4c3775b42a12a534a22c6324ba234464d8804624283b47e9717d8 |
|
MD5 | dd40dc0039187025070b63ce0e85434b |
|
BLAKE2b-256 | 5d04f92cac063174c47ca0fbe1be5cccec4362965e7380abf0a278363721d5cd |