Skip to main content

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']
backup_count = 10
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 deployment
  • console_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 situation
  • backup_count: log backup count
  • format: 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'],
    'backup_count': 10,
    '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.7.tar.gz (15.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

logwrapper-0.1.7-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file logwrapper-0.1.7.tar.gz.

File metadata

  • Download URL: logwrapper-0.1.7.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for logwrapper-0.1.7.tar.gz
Algorithm Hash digest
SHA256 8eab4aac655c52d01022fa882434415935603a8422dcf7460a0f4654f8924265
MD5 9c4e2a9391685a4b62be50f50c692c89
BLAKE2b-256 0ac3b316e7af4f5db7ac1da50478f2bf818ec77dd80a7e43be2a1423f2fb9804

See more details on using hashes here.

File details

Details for the file logwrapper-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: logwrapper-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 16.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for logwrapper-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 ff4febd3a09c4ed795b4122d83cb5dbc85683c7497643d502242ab6ed8f7588f
MD5 7b98675f542b79e00d4a40529c043501
BLAKE2b-256 e8753d89347c82e2424e21e181aa5c26b2c522b44809eefbae56fec46de81884

See more details on using hashes here.

Supported by

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