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
+11k Golang : Generate random elements without repetition or duplicate
+7.5k Golang : Process json data with Jason package
+7.8k Golang : Lock executable to a specific machine with unique hash of the machine
+9k Golang : How to use Gorilla webtoolkit context package properly
+7.7k Gogland : Where to put source code files in package directory for rookie
+6.9k Mac OSX : Find large files by size
+9.5k Golang : Get all countries currencies code in JSON format
+4.7k MariaDB/MySQL : Form select statement or search query with Chinese characters
+11.2k Google Maps URL parameters configuration
+10.6k Golang : How to unmarshal JSON inner/nested value and assign to specific struct?
+6.9k Golang : How to solve "too many .rsrc sections" error?
+21.2k Golang : Get password from console input without echo or masked