Giter Club home page Giter Club logo

config-logger's Introduction

config-logger: Configurable and flexible logger for your python applications

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.

config-logger's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

config-logger's Issues

Filtering option

Provide prepared Filters which are commonly used.

Example Case.
Store in files logging only exceptions for the specified logging level.
eg. For logging.INFO only shows INFO logging only and not ERROR or WARNING

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.