Giter VIP home page Giter VIP logo

epylog's Introduction

EPYLOG

Logs are the first.

This is a simple wrapper to standard logging library for Python.

Epylog provides to send log data to different sources e.g. file, rsyslog, graylog, http, etc.

Use different loggers for different needs and manage it from one place.

build status PyPi status FOSSA Status

Installation

pip install epylog

Usage

  • Move to project root directory and create logging.cfg file:

    cd /project/root
    touch logging.cfg
  • Fill configuration file with you logging settings. Push to targets array everything you want to send to. And fill rules array with logger names (use * wildcard if you want) and set which targets loggers can use:

    {
      "targets": [
          {
            "name": "fl",
            "type":  "file",
            "filename": "/var/log/my_log.log"
          },
          {
            "name": "gl",
            "type":  "graylog",
            "host": "localhost",
            "port": 12202,
            "facility": "test"
          },
          {
            "name": "rsl",
            "type":  "syslog",
            "address": "localhost",
            "facility": "test"
          }
      ],
      "rules": [
          {  
            "name": "my_test_*",
            "min-level": "info",
            "write-to": "fl, gl",
            "format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
          },
          {  
            "name": "*",
             "min-level": "warning",
             "write-to": "rsl",
             "format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
          }
      ]
    }
  • Finally call getLogger function to initialize your logger:

    from epylog import Logger
    
    # put some code here
    
    logger = Logger.getLogger('my_test_logger')
    logger.info('Hello from %s', logger.name)
  • Enjoy sending your logs everywhere

Configuration reference

logging.cfg is a simple JSON object that descxribes all sources that you planning to use and associates loggers with this sources.

Targets

Tagrets are sources where can you send your logs.

...
    {
        "name": "fl",
        "type":  "file",
        ...
    }
...
Field Description
name Unique name of target
type Target type. Now availible file, watch-file, syslog, http and graylog target types
other fields Other fields associated with specific target e.g. filename, host, facility, etc.

Rules

Rules are patterns for associating user loggers with specific configuration.

...
    {  
      "name": "my_test_*",
      "min-level": "info",
      "write-to": "fl, gl",
      "format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
    }
...
Field Description
name Unique name(s) of logger given by getLogger method. Use * wildcard for applying same settings for group of loggers
min-level Minimum logging level
write-to Target names splitted by comma without whitespases that will be asociated with this logger(s)
format Log line format

License

FOSSA Status

epylog's People

Contributors

fossabot avatar iphosgen avatar

Watchers

 avatar

Forkers

fossabot

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.