Skip to main content

Build Status

Travis-CI build status Code Coverage Code Health

Project details

License Pypi Version

Description

The config-logger package is a basic configurable logger. It reads the configuration data for the logging from an external YAML, JSON file or from a given python dictionary and validates it. The contents of this dictionary are described in Configuration dictionary schema. This package is currently tested on Python 2.7.

Installation

pip install config-logger

or

download the latest release and run

python setup.py install

Usage

Configured from external .yaml or .json file

#logging.yaml contains the configuration data which defines the logging in your project

from config_logger import Logger
logger = Logger(name='my_logger', cfg_path='/path/to/logging.yaml')
logger.info("This will be written in a file called info.log")

Console Output

2017-01-31 12:20:32,693 - my_logger - INFO - This will be written in a file called info.log

Configured from dictionary

log_config = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'basic': {
            'format': '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
        }
    },
    'handlers': {
        'console': {
            'class': 'logging.StreamHandler',
            'formatter': 'basic',
            'level': 'WARNING',
            'stream': 'ext://sys.stdout'
        }
    'root': {
        'handlers': ['console'],
        'level': 'WARNING'
    }
}

from config_logger import Logger
logger = Logger(name='my_logger', default_conf=log_config)
logger.warning("This will be written in a file called warning.log")

Console Output

2017-01-31 13:12:56,002 - my_logger - WARNING - This will be written in a file called warning.log

Note: You can find sample of logging configuration files supported by config-logger in this repo.

License

This project is licensed under the MIT license.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

config-logger-1.0.1.tar.gz (5.6 kB view details)

Uploaded Source

File details

Details for the file config-logger-1.0.1.tar.gz.

File metadata

  • Download URL: config-logger-1.0.1.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for config-logger-1.0.1.tar.gz
Algorithm Hash digest
SHA256 e2c6343168c1dc2bda045c6bdf8506f3966788371548dfef54e3c7e68143bfdd
MD5 f6e1916cf5a96813eae41e3c7788feef
BLAKE2b-256 6d095e8c3e08bcf919534cc6132b6f0009faf40090716130092a8d6253929bca

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 Sentry Error logging StatusPage Status page