Giter Site home page Giter Site logo

pyeslog's Introduction

THIS REPOSITORY IS DEPRECATED PLEASE USE THE STANDARD LOGGING LIBRARY OR CONSULT DEPARTMENT ROUTINES

pyeslog

Standard ES Logging Library

Usage

  1. Install the library by placing the following requirement in your requirements.txt
git+https://github.com/epidemicsound/pyeslog.git#egg=pyeslog
  1. Import the Logger in the module
import eslog

logger = eslog.Logger(namespace=__name__)

or

import eslog

logger = eslog.Logger()
  1. Start logging events.
logger.info("A event occured", event_name="my_event", event_type="my_event_type")

Output

The logger logs directly to stdout. A typical log output looks like the following.

{"level": "info", "message": "An event occured", "timestamp": "2018-04-05T08:01:20Z", "event_name": "my_event", "event_type": "my_event_type", "namespace": "test", "service": ""}

The logger will automatically add level, timestamp and service parameters to it.

Examples:

import eslog


logger = eslog.Logger(namespace='module.test', service='service.test')

# Simple Information Logging.
task_id = 'task-321422587'
logger.info("Starting with the task execution", task_id=task_id)

# OUTPUT
{"level": "info", "message": "Starting with the task execution", "timestamp": "2018-04-25T13:24:00Z", "namespace": "module.test", "service": "service.test", "task_id": "task-321422587"}

# Error Logging
error = "Internal System is Unresponsive"
logger.error("Unable to execute the call to third party service", error=error, task_id=task_id)

# OUTPUT
{"level": "error", "message": "Unable to execute the call to third party service", "timestamp": "2018-04-25T13:24:00Z", "error": "Internal System is Unresponsive", "namespace": "module.test", "service": "service.test", "task_id": "task-321422587"}


# Warning Logs
drift = 10
logger.warn("Detected a time drift indicating a possible leak in the system",
            task_id=task_id, drift=drift)

# OUTPUT
{"level": "warn", "message": "Detected a time drift indicating a possible leak in the system", "timestamp": "2018-04-25T13:24:00Z", "drift": 10, "namespace": "module.test", "service": "service.test", "task_id": "task-321422587"}

pyeslog's People

Contributors

alvinlindstam avatar andreashasse avatar edalee avatar parhamfh avatar

Watchers

Daniel Klevebring avatar Christer Sandberg avatar Henrik avatar David Hall avatar Petteri Hyttinen avatar Edvin Ekblad avatar John Häggkvist avatar Per-Anders Legeryd avatar Tim Sneed avatar James Cloos avatar Kristoffer Lannö avatar  avatar Staffan Enberg avatar Ele-Kaja avatar Jens avatar  avatar  avatar Alexandre Pretto Nunes avatar Steve Brazier avatar Robert Sahlin avatar  avatar Martin Strandgren avatar Rikard Herlitz avatar Jesse Tinell avatar Daniel Furtado avatar Mark Schellhas avatar Mats Lexell avatar Fredrik Lindner avatar  avatar Nina Nick avatar Jorge Ramon Letosa avatar Sandra Liljeqvist avatar Andreas avatar Tommi Heikkinen avatar  avatar Sebastian Piwell avatar Alexander Holzmann avatar Hanna the Code Witch ✨ avatar Dennis Komac avatar Abhimanyu Babbar avatar Gustav avatar Marcus Carrigan avatar  avatar Oscar Utterbäck avatar William Chuang Sköld avatar Elizaveta Sigova avatar Mikhail Boronin avatar Harry Sadler avatar Andreas Fundell avatar  avatar Lukas Chripko avatar Alexander Sandor avatar Nikhil Nadig avatar Ersin Sezgin avatar  avatar David D. avatar JB avatar  avatar Linnea Rudenius avatar Günay Abdullayeva avatar  avatar  avatar Fabian Johannsen avatar Eric Grimsborn avatar Thibd avatar

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.