Categorygithub.com/rsms/go-log
modulepackage
0.1.2
Repository: https://github.com/rsms/go-log.git
Documentation: pkg.go.dev

# README

Simple hierarchical Go logger

GitHub tag (latest SemVer) PkgGoDev Go Report Card

  • Serializes all logs on a "background" goroutine
  • If the output writer is a TTY, use terminal colors (disable by unsetting FColor)
  • Hierarchical; SubLogger creates a logger with shared output, level and prefix

Example

func main() {
  log.RootLogger.EnableFeatures(log.FMicroseconds)

  log.Info("Hello")

  log.RootLogger.Level = log.LevelDebug
  log.Debug("Wild %#v", Things{})

  fooLogger := log.SubLogger("[foo]")
  fooLogger.Warn("Danger, Will Robinson")
}
12:54:34.794802 [info] Hello
12:54:34.794826 [debug] Wild Things{Field:0} (log_test.go:18)
12:54:34.794887 [warn] [foo] Danger, Will Robinson

See documentation or log_test.go for more details.

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
NewLogger makes a new logger that is writing to w.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Constants

enable ANSI terminal colors.
enable FColor if w is TTY & env TERM supports colors.
include date (format YYYY-MM-DD).
include source file at end of debug messages.
No description provided by the author
include microseconds in time (format Time.ssssss).
include milliseconds in time (format Time.sss).
enable prefix for LevelDebug ("[debug]").
enable prefix for LevelError ("[error]").
enable prefix for LevelInfo ("[info]").
enable prefix for LevelWarn ("[warn]").
No description provided by the author
write debug messages in a blocking fashion.
write error messages in a blocking fashion.
write info messages in a blocking fashion.
write warning messages in a blocking fashion.
include time (format HH:MM:SS).
date & time in UTC rather than local time zone.
No description provided by the author
log nothing.
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

No description provided by the author

# Structs

No description provided by the author

# Type aliases

behavior.
Level defines the log level.