https://github.com/dreamph/logc
Dynamic Golang Logger (Zap, ZeroLog)
https://github.com/dreamph/logc
golang logger logging zap zerolog
Last synced: 11 days ago
JSON representation
Dynamic Golang Logger (Zap, ZeroLog)
- Host: GitHub
- URL: https://github.com/dreamph/logc
- Owner: dreamph
- License: mit
- Created: 2025-01-02T09:27:43.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-13T03:11:35.000Z (over 1 year ago)
- Last Synced: 2025-02-24T12:19:49.996Z (over 1 year ago)
- Topics: golang, logger, logging, zap, zerolog
- Language: Go
- Homepage:
- Size: 10.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# logc
Golang Logger Wrapper
- Easy for change Log Library Support (zap, zerolog)
- Simple & Easy
Install
=======
``` sh
go get github.com/dreamph/logc
```
Examples - Use Zap
=======
``` go
package main
import (
"context"
"github.com/dreamph/logc"
"github.com/dreamph/logc/zap"
)
func main() {
logger := zap.NewLogger(&logc.Options{
FilePath: "./app.log",
Level: "debug",
Format: "json",
MaxAge: 30,
MaxSize: 10,
})
defer logger.Release()
logger.Info("Test Info")
logger.Warn("Test Warn")
d := map[string]interface{}{
"requestId": "123",
}
log := logger.WithLogger(logc.WithValue(context.Background(), d))
log.Info("Test")
}
```
Examples - Use ZeroLog
=======
``` go
package main
import (
"context"
"github.com/dreamph/logc"
"github.com/dreamph/logc/zerolog"
)
func main() {
logger := zerolog.NewLogger(&logc.Options{
FilePath: "./app.log",
Level: "debug",
Format: "json",
MaxAge: 30,
MaxSize: 10,
})
defer logger.Release()
logger.Info("Test Info")
logger.Warn("Test Warn")
d := map[string]interface{}{
"requestId": "123",
}
log := logger.WithLogger(logc.WithValue(context.Background(), d))
log.Info("Test")
}
```
Buy Me a Coffee
=======
[](https://www.buymeacoffee.com/dreamph)