This commit is contained in:
Liang Ding 2014-12-14 23:16:11 +08:00
parent abfd4ad782
commit 7997393521
2 changed files with 8 additions and 4 deletions

View File

@ -17,6 +17,7 @@
// log.Level = log.Debug
// logger := log.NewLogger(os.Stdout)
//
// logger.Trace("trace message)
// logger.Debug("debug message")
// logger.Info("info message")
// logger.Warn("warning message")
@ -34,7 +35,8 @@ import (
// Logging level.
const (
Debug = iota
Trace = iota
Debug
Info
Warn
Error
@ -76,6 +78,8 @@ func getLevel(level string) int {
level = strings.ToLower(level)
switch level {
case "trace":
return Trace
case "debug":
return Debug
case "info":
@ -96,7 +100,7 @@ func (l *Logger) SetLevel(level string) {
// Trace prints trace level message.
func (l *Logger) Trace(v ...interface{}) {
if Debug < l.level {
if Trace < l.level {
return
}
@ -106,7 +110,7 @@ func (l *Logger) Trace(v ...interface{}) {
// Tracef prints trace level message with format.
func (l *Logger) Tracef(format string, v ...interface{}) {
if Debug < l.level {
if Trace < l.level {
return
}

View File

@ -50,7 +50,7 @@ func init() {
confIP := flag.String("ip", "", "ip to visit")
confPort := flag.String("port", "", "port to visit")
confServer := flag.String("server", "", "this will overwrite Wide.Server if specified")
confLogLevel := flag.String("log_level", "info", "logging level: debug/info/warn/error")
confLogLevel := flag.String("log_level", "info", "logging level: trace/debug/info/warn/error")
confStaticServer := flag.String("static_server", "", "this will overwrite Wide.StaticServer if specified")
confContext := flag.String("context", "", "this will overwrite Wide.Context if specified")
confChannel := flag.String("channel", "", "this will overwrite Wide.XXXChannel if specified")