- SetPrefix
- Prefix
Logging: Set Prefix
- SetPrefix can set the prefix for each log message
- Prefix returns the current prefix
examples/logging-set-prefix/logging_set_prefix.go
package main import ( "log" ) func main() { log.SetPrefix("Foo ") log.Print("First") log.Print("Second") log.SetPrefix("Bar ") log.Print("Third") }
Foo 2020/04/10 09:33:40 First Foo 2020/04/10 09:33:40 Second Bar 2020/04/10 09:33:40 Third