Giter Site home page Giter Site logo

env_logger's Introduction

env_logger

This is a super simple project which aims to help out with setting up logging correctly in your project.

Currently it only supports logrus, but PR's are welcome to support additional loggers.

Usage

The project is fairly simple to use, you include it in your project as if it were a normal logging library. There are currently two ways to setup the log-library. The first is to simply call ConfigureDefaultLogger(). This will set everything up according to the rules specified below. The other is to pass in a preconfigured logger to the project via ConfigureLogger(logger *logrus.Logger) which will be used as the default logger.

The entire logging framework is configured via a single environment variable GOLANG_LOG. The variable is a comma delimited list of packages and their respective log-levels. (falling back to InfoLevel if not configured).

Examples

GOLANG_LOG=foo=debug,bar=warn go run

This configures the foo package at loglevel Debug, the bar package at loglevel Warn and the default/fallback logger at Info.

GOLANG_LOG=foo=info,debug,bar=warn go run

This is the same as the previous example, except foo is now at loglevel Info, and the default loglevel is Debug.

GOLANG_LOG=debug go run

This example sets everything to Debug.

TODO

  • add an interface so that any logger can be injected as the canonical logger (currently only logrus is supported)
type Logger struct {
  New() -> Logger // used to instantiate a new logger
  Debug() // emit debug message
  Info()
  Warn()
  Panic()
}

env_logger's People

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

s00500

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.