Golang log.Prefix and SetPrefix functions example
package log
Golang log.Prefix and SetPrefix functions usage example
package main
import (
"fmt"
"log"
)
func main() {
// Prefix add a string infront of the log message
fmt.Print(log.Prefix())
log.Println("Without prefix")
// Set our log prefix
log.SetPrefix("Log output: ")
fmt.Println(log.Prefix())
log.Println("With prefix")
}
Output :
2015/03/26 14:59:33 Without prefix
Log output:
Log output: 2015/03/26 14:59:33 With prefix
References :
Advertisement
Something interesting
Tutorials
+13.8k Golang : Convert spaces to tabs and back to spaces example
+30.4k Golang : How to redirect to new page with net/http?
+4.1k Javascript : Empty an array example
+10.2k Golang : Check a web page existence with HEAD request example
+15.4k Golang : invalid character ',' looking for beginning of value
+21.7k Golang : Setting up/configure AWS credentials with official aws-sdk-go
+21.8k Golang : How to reverse slice or array elements order
+41.2k Golang : How to count duplicate items in slice/array?
+5.1k Linux/Unix/MacOSX : Find out which application is listening to port 80 or use which IP version
+8.8k Golang : Get final balance from bit coin address example
+7.5k Golang : Dealing with struct's private part
+13k Golang : Get terminal width and height example