GithubHelp home page GithubHelp logo

opencoff / go-logger Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 50 KB

Enhanced logger derived from golang's standard lib

Go 100.00%
backtrace log-crit syslog priority go-logging go-logger logging-library

go-logger's Introduction

go-logger - Level based logger with sub-logger support

What is it?

Borrowed from golang stdlib, this enables logging at increasing levels of verbosity. The verbosity increases as we go down the list below:

  • Emergency (LOG_EMERG) - will halt the program after printing a backtrace of the calling goroutine.
  • Critical (LOG_CRIT)
  • Error (LOG_ERR) - all levels at and above will print a stack-trace of the calling goroutine.
  • Warning (LOG_WARNING)
  • Informational (LOG_INFO) - this is the level at which I log most informational messages useful for troubleshooting production issues.
  • Debug (LOG_DEBUG) - this is the most verbose level

List of enhancements from the stdlib

  • All I/O is done asychronously; the caller doesn't incur I/O cost

  • A single program can have multiple loggers - each with a different priority.

  • An instance of a logger is configured with a given log level; and it only prints log messages "above" the configured level. e.g., if a logger is configured with level of INFO, then it will print all log messages with INFO and higher priority; in particular, it won't print DEBUG messages.

  • A single program can have multiple loggers; each with a different priority.

  • The logger method Backtrace() will print a stack backtrace to the configured output stream. Log levels are NOT considered when backtraces are printed.

  • The Panic() and Fatal() logger methods implicitly print the stack backtrace (upto 5 levels).

  • DEBUG, ERR, CRIT log outputs (via Debug(), Err() and Crit() methods) also print the source file location from whence they were invoked.

  • New package functions to create a syslog(1) or a file logger instance.

  • Callers can create a new logger instance if they have an io.writer instance of their own - in case the existing output streams (File and Syslog) are insufficient.

  • Any logger instance can create child-loggers with a different priority and prefix (but same destination); this is useful in large programs with different modules.

  • Compressed log rotation based on daily time-of-day (configurable ToD) -- only available for file-backed destinations.

  • Wrapper available to make this logger appear like a stdlib logger; this wrapper prints everything sent to it (it's an io.Writer)

go-logger's People

Contributors

opencoff avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 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.