Skip to content

Renni771/simplelogger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

simplelogger

simplelogger is a small logger with no external dependencies. It provides a basic logger API with useful configuration options such as log level, time-stamping and color output.

Installation

Run the following to install simplelogger:

$ go get -u github.com/Renni771/simplelogger

Usage

Simply call the GetLogger function and provide a LoggerOptions struct to configure simplelogger:

  logger := simplelogger.GetLogger(simplelogger.LoggerOptions{
    LogLevel:            simplelogger.LogLevelInfo,
    WithTimeStamps:      true,
    WithColorizedOutput: true,
  })

  logger.Debug("Here's a debug message...")
  logger.Info("Just some info.")
  logger.Warn("I'm warning you!")
  logger.Error("An error occurred!")
  logger.Fatal("Fatality")

Log level

simplelogger supports 7 different log levels with increasing severity:

  LogLevelVerbose   // lowest severity
  LogLevelDebug
  LogLevelInfo
  LogLevelWarn
  LogLevelError
  LogLevelFatal     // highest severity
  LogLevelSilent

Setting the log level to LogLevelWarn will, for example, suppress all LogLevelVerbose, LogLevelDebug, LogLevelInfo logs.

Contributing

Please feel free to fork, extend and improve simplelogger. Any contributions are appreciated.

About

A basic logger written in go.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages