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
+7.9k Setting $GOPATH environment variable for Unix/Linux and Windows
+21.2k Golang : How to force compile or remove object files first before rebuild?
+5.6k PHP : Convert string to timestamp or datestamp before storing to database(MariaDB/MySQL)
+5.2k Golang : PGX CopyFrom to insert rows into Postgres database
+41.4k Golang : Convert string to array/slice
+3.4k Golang : Fix go-cron set time not working issue
+8.5k Golang : How to check variable or object type during runtime?
+21.8k Golang : Upload big file (larger than 100MB) to AWS S3 with multipart upload
+9.1k Golang : Serving HTTP and Websocket from different ports in a program example
+21.6k Golang : GORM create record or insert new record into database example
+9k Golang : How to use Gorilla webtoolkit context package properly
+5k Python : Convert(cast) bytes to string example