Giter VIP home page Giter VIP logo

datadog-custom-logger's Introduction

Datadog Custom Logger

PyPI Open in VS Code

Usage

⚠️ Make sure to setup these 2 environment variables before using this package. You can either set them up by configuring the system environment variables or using python's os.environ[] method

Example

import os
os.environ["DD_API_KEY"] = "" #Your Datadog API Key
os.environ["DD_SITE"] = "datadoghq.com"

Steps

  • Install pip package

    pip install datadog-custom-logger==1.1.1
  • Import package

    from datadog_custom_logger import DatadogCustomLogHandler
  • Initialize the handler

    datadog_custom_handler = DatadogCustomLogHandler(level=logging.INFO)  

    💡Note: if the level is set to logging.WARNING, you won't be able to see info or debug level logs.

Hierarchy:

- debug (logging.DEBUG)
- info (logging.INFO)
- warning (logging.WARNING)
- error (logging.ERROR)
  • Attach the handler

    logging.basicConfig()
    logger = logging.getLogger()
    logger.addHandler(datadog_custom_handler)
    logging.getLogger().setLevel(logging.INFO)
  • Now simply log the logs

    # This statement won't be logged because the .setLevel() is set to logging.INFO.
    # Please check the logging hierarchy for more.
    logging.debug("This is debug level code")
    # This will be logged as per .setLevel()
    logging.info("This is info level logs")

    Complete example:

    datadog-logger-example

datadog-custom-logger's People

Contributors

ivaltryek avatar

Stargazers

Eswari Jayakumar avatar  avatar

Watchers

James Cloos avatar  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.