A logging toolkit
Project description
python-xlogs
logging toolkit
install
pip install xlogs
Usage
1. Use as decorator
from xlogs import log
if __name__ == '__main__':
# config_file: the logging config template, use the default if None
@log(log_dir='./logs',config_file=None)
def division():
pass
2. Load from ini config file
from xlogs import LogConfig
import logging
if __name__ == '__main__':
LogConfig(config_file= '/xxx.ini', log_file = '/xxx/')
logging.info('Default load to root')
info = logging.getLogger('root')
info.info('write msg to test.log')
info = logging.getLogger('test')
info.info('write msg to message.log')
info = logging.getLogger('info')
info.info('write msg to info.log')
error = logging.getLogger('error')
error.error('write msg to error.log')
# reload a new config file
LogConfig(config_file= '/yyy.ini', log_file = '/yyy/').reset()
logging.getLogger().info("info with new logger")
3. config with args
from xlogs import get_logger
if __name__ == '__main__':
logger = get_logger(debug=True, logfile='/message.log')
logger.info("info oooooo")
logger.debug("debug ggggg")
logger.error("err rrrr")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
xlogs-1.0.3.tar.gz
(12.7 kB
view hashes)
Built Distribution
xlogs-1.0.3-py2.py3-none-any.whl
(13.4 kB
view hashes)
Close
Hashes for xlogs-1.0.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6cfe7376e1e008bb49c745716b845d710dc2baa427696028f06d66702fd4e22 |
|
MD5 | 02d9bf6e569443496938c7b16d71c950 |
|
BLAKE2b-256 | 3ac562e54a017693755776f7efddebc36eddade84329bd5210969e13a4f0f064 |