Skip to main content

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


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 details)

Uploaded Source

Built Distribution

xlogs-1.0.3-py2.py3-none-any.whl (13.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file xlogs-1.0.3.tar.gz.

File metadata

  • Download URL: xlogs-1.0.3.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.0

File hashes

Hashes for xlogs-1.0.3.tar.gz
Algorithm Hash digest
SHA256 b7e045fc960469e9c6558ceea627ef5eca3fa6480fac88de248a0285d52fe2bf
MD5 8ca3d9d9e949962f3c91c1a8e974d979
BLAKE2b-256 b65b4a51014796d54d1bae76b1c8293b44858d87ff63fe01ed345189ce6ea319

See more details on using hashes here.

File details

Details for the file xlogs-1.0.3-py2.py3-none-any.whl.

File metadata

  • Download URL: xlogs-1.0.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 13.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.0

File hashes

Hashes for xlogs-1.0.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e6cfe7376e1e008bb49c745716b845d710dc2baa427696028f06d66702fd4e22
MD5 02d9bf6e569443496938c7b16d71c950
BLAKE2b-256 3ac562e54a017693755776f7efddebc36eddade84329bd5210969e13a4f0f064

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page