https://github.com/aacfactory/logs
logs for go
https://github.com/aacfactory/logs
log
Last synced: 5 months ago
JSON representation
logs for go
- Host: GitHub
- URL: https://github.com/aacfactory/logs
- Owner: aacfactory
- License: apache-2.0
- Created: 2021-07-14T07:45:34.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-01-04T06:57:47.000Z (over 2 years ago)
- Last Synced: 2024-01-04T07:25:47.856Z (over 2 years ago)
- Topics: log
- Language: Go
- Homepage:
- Size: 45.9 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 概述
LOGS 是一个 AAC FACTORY 的 LOG 规范。
## 获取
```go
go get github.com/aacfactory/logs
```
## 使用
```go
log, logErr := logs.New(
logs.WithLevel(logs.DebugLevel),
)
// handle logErr
// print
log.Debug().Caller().With("f1", "f1").With("f2", 2).Message("debug")
log.Info().With("time", time.Now()).Message("info")
log.Warn().Caller().Message("warn")
log.Error().Caller().Cause(errors.New("some error")).Message("error")
// shutdown
shutdownErr := log.Shutdown(context.Background())
```
## 压测
```shell
BenchmarkLogger_Info-20 1602939 744.5 ns/op 243 B/op 5 allocs/op
```