Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/myriad-dreamin/screenrus
Simple ANSI-Highlight Pretified Screen-Logger Hook for logrus
https://github.com/myriad-dreamin/screenrus
Last synced: about 1 month ago
JSON representation
Simple ANSI-Highlight Pretified Screen-Logger Hook for logrus
- Host: GitHub
- URL: https://github.com/myriad-dreamin/screenrus
- Owner: Myriad-Dreamin
- Created: 2019-07-02T16:59:10.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-07-03T05:58:08.000Z (over 5 years ago)
- Last Synced: 2024-06-20T16:47:24.143Z (5 months ago)
- Language: Go
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Screen-rus
easiest usage:
```go
sss := log.New()
a, err := NewScreenLogPlugin(nil)
if err != nil {
t.Error(err)
return
}
sss.AddHook(a)
ssr := sss.WithFields(log.Fields{
"prog": "cmd",
})
ssr.Infof("love t")
ssr.Errorf("love WW")>---------------------------------------------------
INFO[2019-07-03 01:02:15] love t prog=cmd
time="2019-07-03T01:02:15+08:00" level=info msg="love t" prog=cmd
ERRO[2019-07-03 01:02:15] love WW prog=cmd
time="2019-07-03T01:02:15+08:00" level=error msg="love WW" prog=cmd
```set level:
```go
sss := log.New()
a, err := NewScreenLogPlugin([]OptionItem{
OptionItem{K: "Level", V: []logrus.Level{log.WarnLevel, log.InfoLevel}},
})
if err != nil {
t.Error(err)
return
}
sss.AddHook(a)
ssr := sss.WithFields(log.Fields{
"prog": "cmd",
})
ssr.Infof("love t")
ssr.Errorf("love WW")>---------------------------------------------------
INFO[2019-07-03 01:02:15] love t prog=cmd
time="2019-07-03T01:02:15+08:00" level=info msg="love t" prog=cmd
time="2019-07-03T01:02:15+08:00" level=error msg="love WW" prog=cmd
```following is all the options you can set:
| Key Name | Value Type | Defalut |
| --------------- | -------------- | --------------------- |
| ForceColors | bool | true |
| FullTimestamp | bool | true |
| TimestampFormat | string | "2006-01-02 15:04:05" |
| Level | []logrus.Level | log.AllLevels |