Python log wrapper
Project description
README
Table of Contents
Python log wrapper
Example configuration
[log]
project = 'Project'
console = true
console_level = 'DEBUG'
file = true
file_level = 'INFO'
log_file = 'logs/log.log'
max_size = 10240000
backup_count = 10
format = '%(asctime)s | %(levelname)s | <%(threadName)s> %(module)s.%(funcName)s [%(lineno)d]: %(message)s'
project
: project name, used to initialize loggerconsole
: whether to output log to STDOUT, use it during debugging, and close it during formal deploymentconsole_level
: log level, optional values are 'DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'file
: whether to output log to filefile_level
: log level, optional values are 'DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'log_file
: log file pathmax_size
: log file size, the unit is KBbackup_count
: maximum number of log filesformat
: format of the log
Usage
import logging
from logwrapper import logger_name, setup_logging
loggername = logger_name(file=__file__, tier=1)
logger = logging.getLogger(loggername)
logger.info('Action')
NOTE:
-
The
tier
parent folder offile
is theproject
nameE.g:
file = /home/example/Project/src/main.py
,tier = 2
, return resultloggername = Project.src.main
, namelyproject = Project
, which matches the configuration item
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.0.5.tar.gz
(15.8 kB
view hashes)
Built Distribution
logwrapper-0.0.5-py3-none-any.whl
(16.3 kB
view hashes)
Close
Hashes for logwrapper-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2aaadca20c2682bb419c74045ac46b316815261ef6f83e9af49b8161ee22523f |
|
MD5 | 3269fa37ec4f7fa5cbb3fadc1daa7a71 |
|
BLAKE2b-256 | 95b065a7dc05839b3e47cf24ef9bb3a467c1dde49b29983f0b43ab934d017a95 |