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
+16.3k Golang : How to extract links from web page ?
+14.5k Golang : Rename directory
+19.3k Golang : Calculate entire request body length during run time
+4.7k JavaScript: Add marker function on Google Map
+9.9k Golang : Ordinal and Ordinalize a given number to the English ordinal numeral
+6.9k Golang : How to setup a disk space used monitoring service with Telegram bot
+3.4k Golang : Fix go-cron set time not working issue
+7.1k Golang : Validate credit card example
+5.8k Golang : Markov chains to predict probability of next state example
+4.6k MariaDB/MySQL : How to get version information
+11.6k Golang : Simple file scaning and remove virus example