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
+9k Golang : Go as a script or running go with shebang/hashbang style
+8.6k Golang : Progress bar with ∎ character
+11.6k Golang : Simple file scaning and remove virus example
+41k Golang : How to check if a string contains another sub-string?
+12.4k Elastic Search : Return all records (higher than default 10)
+17.4k Golang : Multi threading or run two processes or more example
+87.8k Golang : How to convert character to ASCII and back
+7k Golang : Takes a plural word and makes it singular
+18.3k Golang : Get path name to current directory or folder
+37.7k Golang : Comparing date or timestamp
+17.9k Golang : Login and logout a user after password verification and redirect example
+11.7k Golang : Secure file deletion with wipe example