https://github.com/thehungry-dev/cog
Cog provides the building blocks for creating the logging mechanism tailored to the need of your software
https://github.com/thehungry-dev/cog
go golang logging logging-framework
Last synced: 29 days ago
JSON representation
Cog provides the building blocks for creating the logging mechanism tailored to the need of your software
- Host: GitHub
- URL: https://github.com/thehungry-dev/cog
- Owner: thehungry-dev
- License: mit
- Created: 2021-06-19T14:46:23.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-06-24T06:24:15.000Z (over 4 years ago)
- Last Synced: 2024-06-20T20:36:17.496Z (over 1 year ago)
- Topics: go, golang, logging, logging-framework
- Language: Go
- Homepage:
- Size: 92.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Cog
Cog provides the building blocks for creating the logging mechanism
tailored to the need of your software.
## Usage
```go
package mypkg
import (
"github.com/thehungry-dev/cog"
"github.com/thehungry-dev/cog/handler"
"github.com/thehungry-dev/cog/message/field"
"github.com/thehungry-dev/cog/message/transform"
"github.com/thehungry-dev/cog/settings"
)
var Log cog.Writer
func init() {
set := settings.Getenv()
device := set.Device()
// Builds a writer that can filter log output by level, by tag and outputs colored log messages
Log = cog.With(
handler.BuildPipe(
set.LevelFilter(),
set.TagFilter(),
handler.BuildOutput(device, handler.OutputText),
),
)
}
```
```go
package main
func main() {
log := mypkg.Log
fields := field.Builder{}
log.Info("some message")
log.Tags("tag1", "tag2").Warn("some message")
log.
Tags("tag1", "data").
Data(
fields.String("Name", "some name"),
fields.Bool("SomeBool", true)
).
Fatalf("Interpolated %s", "message")
}
```