const ( // CRITICAL is the lowest log level; only errors which will end the program will be propagated. CRITICAL LogLevel = iota - 1 // ERROR is for errors that are not fatal but lead to troubling behavior. ERROR // WARNING is for errors which are not fatal and not errors, but are unusual. Often sourced from misconfigurations. WARNING // NOTICE is for normal but significant conditions. NOTICE // INFO is a log level for common, everyday log updates. INFO // DEBUG is the default hidden level for more verbose updates about internal processes. DEBUG // TRACE is for (potentially) call by call tracing of programs. TRACE )
代码中解释的很直观,而在具体日志中,都是以缩写的形式显示,如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
switch l { case CRITICAL: return "C" case ERROR: return "E" case WARNING: return "W" case NOTICE: return "N" case INFO: return "I" case DEBUG: return "D" case TRACE: return "T" default: panic("Unhandled loglevel") }