Golang log.SetFlags() function example
package log
Golang log.SetFlags() function usage example
package main
import (
"log"
)
func main() {
log.Println(log.Flags())
// set flags to change the log output
log.SetFlags(log.Ldate)
log.Println(log.Flags())
// set flags to change the log output again
log.SetFlags(log.LstdFlags | log.Lshortfile)
log.Println(log.Flags())
}
Output :
2015/03/26 15:15:18 3
2015/03/26 1
2015/03/26 15:15:18 prefixlog.go:19: 19
Reference :
Advertisement
Something interesting
Tutorials
+20.6k Nginx + FastCGI + Go Setup.
+16.5k Golang : Execute terminal command to remote machine example
+8.7k Golang : Find duplicate files with filepath.Walk
+17.6k Golang : Parse date string and convert to dd-mm-yyyy format
+6.3k Golang : How to get capacity of a slice or array?
+14k Golang : Fix cannot use buffer (type bytes.Buffer) as type io.Writer(Write method has pointer receiver) error
+19.6k Golang : Close channel after ticker stopped example
+3.6k Java : Get FX sentiment from website example
+22.7k Golang : Round float to precision example
+28.2k Golang : Connect to database (MySQL/MariaDB) server
+8.2k Golang : Metaprogramming example of wrapping a function
+11.3k Golang : Post data with url.Values{}