https://github.com/gernest/logray
Logray
https://github.com/gernest/logray
Last synced: about 2 months ago
JSON representation
Logray
- Host: GitHub
- URL: https://github.com/gernest/logray
- Owner: gernest
- License: apache-2.0
- Created: 2016-03-17T19:27:44.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-03-17T19:28:32.000Z (about 9 years ago)
- Last Synced: 2025-01-12T19:25:50.351Z (4 months ago)
- Language: Go
- Homepage:
- Size: 942 KB
- Stars: 0
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Logray
## Goals
### Multiple outputs
Our previous library had this, and logrus does through hooks. This is important to start using syslog.
(As an aside, the hooks approach is odd. In terms of practicality, you could view writing to syslog as more of an output instead of hook. Additionally, it makes sense to configure it as you would an output, with things like the loglevels it should send there. Additionally, viewing the formatter and output as two separate things like logrus does does not mesh with our outstanding).
### Field propagation
Logrus added a fields map which allowed for more valuable metadata. We liked this and wanted to extend it, but logrus didn’t have fields building on fields. We wanted to take a context and pass it further down into the system, and have the fields build upon it as its actions got more specific. Logrus only lets you do a WithFields, which gave you an Entry, and could write multiple things on that, but couldn’t really have it turtle further down.
### Contextually specific log formatting
At different places in the system, you care about different data related to log messages. The logging changes allow formats/outputs to be overwritten in certain places where the format we see directly matters in a slightly different way.
### Simple to use
This library needed to be simple to use. So starting out, basically all you have have to do is write logger := logray.New() to start logging. (Note, perhaps writing to stdout by default should be added to the library). Want to add dields? You can write logger.SetField(key, value). Want to pass it further down where separate fields might be set? That's just logger2 := logger.Clone().