This commit is contained in:
parent
abfd4ad782
commit
7997393521
10
log/logs.go
10
log/logs.go
|
@ -17,6 +17,7 @@
|
||||||
// log.Level = log.Debug
|
// log.Level = log.Debug
|
||||||
// logger := log.NewLogger(os.Stdout)
|
// logger := log.NewLogger(os.Stdout)
|
||||||
//
|
//
|
||||||
|
// logger.Trace("trace message)
|
||||||
// logger.Debug("debug message")
|
// logger.Debug("debug message")
|
||||||
// logger.Info("info message")
|
// logger.Info("info message")
|
||||||
// logger.Warn("warning message")
|
// logger.Warn("warning message")
|
||||||
|
@ -34,7 +35,8 @@ import (
|
||||||
|
|
||||||
// Logging level.
|
// Logging level.
|
||||||
const (
|
const (
|
||||||
Debug = iota
|
Trace = iota
|
||||||
|
Debug
|
||||||
Info
|
Info
|
||||||
Warn
|
Warn
|
||||||
Error
|
Error
|
||||||
|
@ -76,6 +78,8 @@ func getLevel(level string) int {
|
||||||
level = strings.ToLower(level)
|
level = strings.ToLower(level)
|
||||||
|
|
||||||
switch level {
|
switch level {
|
||||||
|
case "trace":
|
||||||
|
return Trace
|
||||||
case "debug":
|
case "debug":
|
||||||
return Debug
|
return Debug
|
||||||
case "info":
|
case "info":
|
||||||
|
@ -96,7 +100,7 @@ func (l *Logger) SetLevel(level string) {
|
||||||
|
|
||||||
// Trace prints trace level message.
|
// Trace prints trace level message.
|
||||||
func (l *Logger) Trace(v ...interface{}) {
|
func (l *Logger) Trace(v ...interface{}) {
|
||||||
if Debug < l.level {
|
if Trace < l.level {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +110,7 @@ func (l *Logger) Trace(v ...interface{}) {
|
||||||
|
|
||||||
// Tracef prints trace level message with format.
|
// Tracef prints trace level message with format.
|
||||||
func (l *Logger) Tracef(format string, v ...interface{}) {
|
func (l *Logger) Tracef(format string, v ...interface{}) {
|
||||||
if Debug < l.level {
|
if Trace < l.level {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
main.go
2
main.go
|
@ -50,7 +50,7 @@ func init() {
|
||||||
confIP := flag.String("ip", "", "ip to visit")
|
confIP := flag.String("ip", "", "ip to visit")
|
||||||
confPort := flag.String("port", "", "port to visit")
|
confPort := flag.String("port", "", "port to visit")
|
||||||
confServer := flag.String("server", "", "this will overwrite Wide.Server if specified")
|
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")
|
confStaticServer := flag.String("static_server", "", "this will overwrite Wide.StaticServer if specified")
|
||||||
confContext := flag.String("context", "", "this will overwrite Wide.Context if specified")
|
confContext := flag.String("context", "", "this will overwrite Wide.Context if specified")
|
||||||
confChannel := flag.String("channel", "", "this will overwrite Wide.XXXChannel if specified")
|
confChannel := flag.String("channel", "", "this will overwrite Wide.XXXChannel if specified")
|
||||||
|
|
Loading…
Reference in New Issue