1 개요[ | ]
- logrus
Go
Copy
package main
import (
log "github.com/sirupsen/logrus"
)
func main() {
log.Trace("Something very low level.")
log.Debug("Useful debugging information.")
log.Info("Something noteworthy happened!")
log.Warn("You should probably take a look at this.")
log.Error("Something failed but I'm not quitting.")
}
Loading
Go
Copy
package main
import (
log "github.com/sirupsen/logrus"
)
func main() {
log.SetLevel(log.DebugLevel)
log.SetReportCaller(true)
log.Trace("Something very low level.")
log.Debug("Useful debugging information.")
log.Info("Something noteworthy happened!")
log.Warn("You should probably take a look at this.")
log.Error("Something failed but I'm not quitting.")
}
Loading
Go
Copy
package main
import (
"path"
"runtime"
"strings"
log "github.com/sirupsen/logrus"
)
func main() {
log.SetReportCaller(true)
log.SetLevel(log.DebugLevel)
log.SetFormatter(&log.TextFormatter{
FullTimestamp: true,
CallerPrettyfier: func(f *runtime.Frame) (string, string) {
s := strings.Split(f.Function, ".")
funcname := s[len(s)-1]
_, filename := path.Split(f.File)
return funcname, filename
},
})
log.Trace("Something very low level.")
log.Debug("Useful debugging information.")
log.Info("Something noteworthy happened!")
log.Warn("You should probably take a look at this.")
log.Error("Something failed but I'm not quitting.")
}
Loading
Go
Copy
package main
import (
"fmt"
log "github.com/sirupsen/logrus"
)
func main() {
err := fmt.Errorf("hello")
log.Errorf("error: %s", err.Error())
}
Loading
2 같이 보기[ | ]
3 참고[ | ]
편집자 Jmnote
로그인하시면 댓글을 쓸 수 있습니다.