Skip to main content

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 logger
  • console: whether to output log to STDOUT, use it during debugging, and close it during formal deployment
  • console_level: log level, optional values are 'DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'
  • file: whether to output log to file
  • file_level: log level, optional values are 'DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'
  • log_file: log file path
  • max_size: log file size, the unit is KB
  • backup_count: maximum number of log files
  • format: 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:

  1. The tier parent folder of file is the project name

    E.g: file = /home/example/Project/src/main.py, tier = 2, return result loggername = Project.src.main, namely project = 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)

Uploaded Source

Built Distribution

logwrapper-0.0.5-py3-none-any.whl (16.3 kB view hashes)

Uploaded Python 3

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