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
+9.6k Golang : How to generate Code 39 barcode?
+21.6k Golang : GORM create record or insert new record into database example
+10.2k Golang : Use regular expression to get all upper case or lower case characters example
+29.5k Golang : Login(Authenticate) with Facebook example
+13.9k Golang : Get current time
+10.3k Golang : How to check if a website is served via HTTPS
+17.9k Golang : How to make a file read only and set it to writable again?
+20k Golang : Convert(cast) bytes.Buffer or bytes.NewBuffer type to io.Reader
+13.2k Golang : Skip blank/empty lines in CSV file and trim whitespaces example
+35.3k Golang : Strip slashes from string example
+4.7k Javascript : Access JSON data example
+24.5k Golang : Change file read or write permission example