https://github.com/chambo-e/logry
A zero configuration logrus with sentry integration
https://github.com/chambo-e/logry
golang logger logging logrus logrus-hook sentry
Last synced: 2 months ago
JSON representation
A zero configuration logrus with sentry integration
- Host: GitHub
- URL: https://github.com/chambo-e/logry
- Owner: chambo-e
- License: mit
- Created: 2017-04-08T13:28:12.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-08T14:33:50.000Z (about 9 years ago)
- Last Synced: 2024-06-20T06:42:55.975Z (about 2 years ago)
- Topics: golang, logger, logging, logrus, logrus-hook, sentry
- Language: Go
- Size: 225 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `logry` [](https://godoc.org/github.com/chambo-e/logry)
## Description
`logry` is a painless logging package with sentry integration.
It's a simple [`logrus`](https://github.com/sirupsen/logrus) with a bundled [Sentry](https://sentry.io/) integration thanks to [`logrus_sentry`](https://github.com/evalphobia/logrus_sentry).
## Usage
```go
package main
import (
"github.com/chambo-e/logry"
)
func main() {
logry.Debugln("Will be printed on stdout except if APP_ENV=production")
logry.Println("Will be printed on stdout")
logry.Errorln("Will be printed on stderr and sent to Sentry")
logry.Fatalln("Will be printed on stderr and sent to Sentry")
logry.Panicln("Will be printed on stderr and sent to Sentry")
}
```
```bash
$ SENTRY_DSN=https://xxx:yyy@domain.com/XXX go run main.go
```
## Difference with `logrus`
You can do everything you were doing with `logrus` with `logry`, they expose the exact same interface.
There is only one main difference, the default log level is logrus.DebugLevel. You can change it with SetLevel or by setting env var `APP_ENV=production`.
`logry` reads you project DSN from app env var `SENTRY_DSN`. Default is an empty DSN and just disable the sentry exception logging.
These message levels are sent to sentry:
```go
[]logrus.Level{
logrus.PanicLevel,
logrus.FatalLevel,
logrus.ErrorLevel,
}
```
`logry` also expose two additional methods:
```go
// To set sentry environment tag
// Default value is "development" and can be changed with APP_ENV
logry.SetEnvironment("lala")
// To set sentry release tag
logry.SetRelease("1.0.0")
```
### Contributions
Contributions are more than welcome as usual, feel free to open an issue :)
### Tests
There is no tests on this project because everything this package does is inside an hard to test init() function. But if this is an issue for some of you I'll be open to discuss on how it could be made.