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
+15k Golang : Search folders for file recursively with wildcard support
+19.1k Mac OSX : Homebrew and Golang
+7.5k Golang : Handling Yes No Quit query input
+7k Golang : Takes a plural word and makes it singular
+12.7k Golang : Pass database connection to function called from another package and HTTP Handler
+10.1k Golang : Edge detection with Sobel method
+15.8k Golang : Get digits from integer before and after given position example
+6.3k Golang : Selection sort example
+19.1k Golang : Display list of time zones with GMT
+17.9k Golang : How to make a file read only and set it to writable again?
+12.7k Golang : Sort and reverse sort a slice of bytes