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
+17k Golang : Covert map/slice/array to JSON or XML format
+14.4k Golang : On enumeration
+8.7k Golang : Combine slices but preserve order example
+13.9k Golang : How to determine if a year is leap year?
+9.1k Golang : How to capture return values from goroutines?
+7.6k Android Studio : AlertDialog to get user attention example
+7.7k Golang : Mapping Iban to Dunging alphabets
+6.5k Unix/Linux : How to get own IP address ?
+29.2k Golang : missing Git command
+10.6k Golang : How to unmarshal JSON inner/nested value and assign to specific struct?
+19.5k Golang : How to Set or Add Header http.ResponseWriter?
+5.6k PHP : Convert CSV to JSON with YQL example