Go语言学习之log包(The way to go)
生命不止,继续go go go!!!
讲真,go为我们提供的log package的功能挺简单的,但是常规的功能够用了,我们就进行简简单单的介绍。之后,会自己封装自己log,比如用来记录我们的http日志等。
import( “log” )
Package log implements a simple logging package. It defines a type, Logger, with methods for formatting output. It also has a predefined ‘standard’ Logger accessible through helper functions Print[f|ln], Fatal[f|ln], and Panic[f|ln], which are easier to use than creating a Logger manually. That logger writes to standard error and prints the date and time of each logged message. Every log message is output on a separate line: if the message being printed does not end in a newline, the logger will add one. The Fatal functions call os.Exit(1) after writing the log message. The Panic functions call panic after writing the log message.
log中的常量标志
const (
还没有评论,来说两句吧...