Golang log.Flags function example

package log

Golang log.Flags function usage example

 package main

 import (
 "fmt"
 "log"
 )

 func main() {

 fmt.Println("standard flags :", log.Flags())

 // the flags constants
 // see http://golang.org/pkg/log/#pkg-constants
 fmt.Println("The date : ", log.Ldate)
 fmt.Println("The time : ", log.Ltime)
 fmt.Println("The microsecond resolution : ", log.Lmicroseconds)
 fmt.Println("The full file name and line number : ", log.Llongfile)
 fmt.Println("The final file name element and line number : ", log.Lshortfile)
 fmt.Println("The initial values for the standard logger : ", log.LstdFlags) //LstdFlags = Ldate | Ltime
 }

Output :

standard flags : 3

The date : 1

The time : 2

The microsecond resolution : 4

The full file name and line number : 8

The final file name element and line number : 16

The initial values for the standard logger : 3

References :

http://golang.org/pkg/log/#pkg-constants http://golang.org/pkg/log/#Flags

Advertisement