Golang logging: Difference between revisions
From wikinotes
(Created page with "Logging is a standardized format of writing progress/debug info. = Example = <blockquote> <syntaxhighlight lang="go"> // ./logger.go package main import "os" import "log" // params: // 1. device you'd like to log to // 2. log-prefix of this logger // 3. log-formatting options // var Logger = log.New(os.Stderr, "", log.Ldate|log.Ltime|log.Lshortfile) </syntaxhighlight> <syntaxhighlight lang="go"> // ./main.go package main func main() { Logger.Println("th...") |
(No difference)
|
Revision as of 21:30, 18 June 2022
Logging is a standardized format of writing progress/debug info.
Example
// ./logger.go package main import "os" import "log" // params: // 1. device you'd like to log to // 2. log-prefix of this logger // 3. log-formatting options // var Logger = log.New(os.Stderr, "", log.Ldate|log.Ltime|log.Lshortfile)// ./main.go package main func main() { Logger.Println("this is a test") }go run main.go logger.go # build/run