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
+4.6k MariaDB/MySQL : How to get version information
+11k Golang : Generate random elements without repetition or duplicate
+16.4k Golang : Send email and SMTP configuration example
+22.9k Golang : Gorilla mux routing example
+10.5k Golang : Generate 403 Forbidden to protect a page or prevent indexing by search engine
+4.9k HTTP common errors and their meaning explained
+25.4k Golang : Convert long hexadecimal with strconv.ParseUint example
+29.4k Golang : JQuery AJAX post data to server and send data back to client example
+9.9k Golang : Sort and reverse sort a slice of integers
+22.1k Golang : Repeat a character by multiple of x factor
+6.4k CodeIgniter : form input set_value cause " to become & quot
+7.9k Golang : Ways to recover memory during run time.