https://github.com/goapt/logger
golang logger
https://github.com/goapt/logger
go-lang logrus sentry
Last synced: 3 months ago
JSON representation
golang logger
- Host: GitHub
- URL: https://github.com/goapt/logger
- Owner: goapt
- License: mit
- Created: 2018-06-26T14:15:42.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-07-09T03:33:26.000Z (over 4 years ago)
- Last Synced: 2025-08-13T20:42:33.068Z (5 months ago)
- Topics: go-lang, logrus, sentry
- Language: Go
- Size: 141 KB
- Stars: 6
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Logger
Golang logger,Integrate logrus and sentry,support logroate
## Default logger
default log out to os.Stderr
```go
import "github.com/goapt/logger"
func main(){
logger.Debug("debug printer %s","hehe")
logger.Fatal("exit")
}
```
## Setting default logger
```
logger.Setting(func(c *logger.Config) {
c.LogMode = "file"
c.LogLevel = "info"
c.LogMaxFiles = 15 //store for up to 15 days
c.LogPath = "/tmp/logs/"
c.LogSentryDSN = ""
c.LogSentryType = ""
c.LogDetail = true
})
```
## New logger
```
log := logger.NewLogger(func(c *logger.Config) {
c.LogMode = "file"
c.LogLevel = "info"
c.LogMaxFiles = 15 //store for up to 15 days
c.LogPath = "/tmp/logs/"
c.LogSentryDSN = ""
c.LogSentryType = ""
})
log.Debug("this is new log")
```
## Print filename and line no
if `LogDetail` is true,the log data add filename and line no
```
{"file":"/Users/fifsky/wwwroot/go/library/src/github.com/fifsky/goblog/handler/index.go","func":"handler.IndexGet","level":"debug","line":16,"msg":"[test]","time":"2018-08-02 22:37:02"}
```
## Log Data
```
logger.Data(map[string]interface{}{
"id": 1,
"name": "test",
}).Info("[CURL ERROR]", "123123")
```
```
{"data":{"id":1,"name":"test"},"level":"info","msg":"[CURL ERROR]123123","time":"2019-01-18 17:05:17"}
```