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.3k Golang : Date and Time formatting
+13.6k Golang : Query string with space symbol %20 in between
+23.1k Golang : Randomly pick an item from a slice/array example
+14.5k How to automatically restart your crashed Golang server
+48.5k Golang : Upload file from web browser to server
+12.2k Linux : How to install driver for 600Mbps Dual Band Wifi USB Adapter
+7.3k Golang : alternative to os.Exit() function
+14.9k Golang : Submit web forms without browser by http.PostForm example
+21.8k SSL : How to check if current certificate is sha1 or sha2
+12.6k Golang : Drop cookie to visitor's browser and http.SetCookie() example
+34.1k Golang : Create x509 certificate, private and public keys
+7.9k Golang : Trim everything onward after a word