Skip to main content

For many simple cases, there is a ready to use global variable already definelogger defined in the log package, log packagelog.Logger. ThatThis global variablelogger can be configured through configuredlog.SetFlags.

Afterwards one can just call the top level functions of the log package (likelike log.Printf, and log.Fatalf, ...), which use that global instance - even though the variable is not exported per se.

For many simple cases there is a ready to use global variable already define in the log package. That global variable can be configured.

Afterwards one can just call the top level functions of the log package (like log.Printf, log.Fatalf, ...), which use that global instance - even though the variable is not exported per se.

For simple cases, there is a global logger defined in the log package, log.Logger. This global logger can be configured through log.SetFlags.

Afterwards one can just call the top level functions of the log package like log.Printf and log.Fatalf, which use that global instance.

Source Link
zzzz
  • 91k
  • 17
  • 181
  • 140

For many simple cases there is a ready to use global variable already define in the log package. That global variable can be configured.

Afterwards one can just call the top level functions of the log package (like log.Printf, log.Fatalf, ...), which use that global instance - even though the variable is not exported per se.