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
+21.2k Golang : Clean up null characters from input data
+5.2k Golang : Issue HTTP commands to server and port example
+7.4k Golang : Individual and total number of words counter example
+25.5k Golang : Generate MD5 checksum of a file
+18.2k Golang : Get command line arguments
+10.2k Golang : Find and replace data in all files recursively
+11.3k Golang : Intercept and process UNIX signals example
+13.1k Golang : List objects in AWS S3 bucket
+8.8k Golang : Heap sort example
+6k Javascript : Get operating system and browser information
+7.9k Golang : Get today's weekday name and calculate target day distance example
+5.8k Golang : Launching your executable inside a console under Linux