Categorygithub.com/chinglinwen/log
repositorypackage
0.0.0-20180802093412-402fdc33bf76
Repository: https://github.com/chinglinwen/log.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

log

log package from upspin. ( by the same Golang authors )

Usage

Default level

Info

use flag or environment variable to set different default level through init.

call log.SetLevel("debug") to change level.

Log

log.Print...
log.Debug.Print...

Where info ( added a extra function to the original log package )

Where function usage example:

log.Printf("%v some error info here\n", log.Where())

Log file setting ( size, rotate, etc. )

See http://github.com/natefinch/lumberjack

log.SetOutput(&lumberjack.Logger{
    Filename:   "/var/log/myapp/foo.log",
    MaxSize:    500, // megabytes
    MaxBackups: 3,
    MaxAge:     28, //days
})

Example code to support turn on debug output on the fly

See doc/support-debug-on-the-fly

Other packages considered (but not choose it)

(for the record here only, use above one )

Reference article about log

I believe that there are only two things you should log:

  • Things that developers care about when they are developing or debugging software.
  • Things that users care about when using your software.

Obviously these are debug and info levels, respectively.

https://dave.cheney.net/2015/11/05/lets-talk-about-logging