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
+17.5k Golang : Linked list example
+8.1k Golang : How To Use Panic and Recover
+10.1k Golang : Compare files modify date example
+14.1k Javascript : Prompt confirmation before exit
+9.1k Golang : Intercept and compare HTTP response code example
+29.1k Golang : Get first few and last few characters from string
+13.2k Golang : Convert(cast) int to int64
+5.4k Golang : Return multiple values from function
+6.9k Nginx : Password protect a directory/folder
+9.5k Mac OSX : Get a process/daemon status information
+11.8k Golang : convert(cast) float to string
+8.9k Golang : Sort lines of text example