Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pantani/logger
Simple log package.
https://github.com/pantani/logger
go golang log log-handler logger logging logging-helper
Last synced: about 7 hours ago
JSON representation
Simple log package.
- Host: GitHub
- URL: https://github.com/pantani/logger
- Owner: Pantani
- License: mit
- Created: 2020-03-28T15:48:03.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-02-26T01:33:33.000Z (over 3 years ago)
- Last Synced: 2024-06-21T15:16:36.702Z (5 months ago)
- Topics: go, golang, log, log-handler, logger, logging, logging-helper
- Language: Go
- Homepage:
- Size: 11.7 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Go Reference](https://pkg.go.dev/badge/github.com/Pantani/logger.svg)](https://pkg.go.dev/github.com/Pantani/logger)
[![codecov](https://codecov.io/gh/Pantani/logger/branch/master/graph/badge.svg?token=3CHQF7L76B)](https://codecov.io/gh/Pantani/logger)# Simple log package
Simple abstraction for logs using [Logrus](https://github.com/sirupsen/logrus).
E.g.:
- Log message:
```go
logger.Info("Loading Observer API")
```- Log message with params:
```go
logger.Info("Running application", logger.Params{"bind": bind})
```- Fatal with error:
```go
logger.Fatal("Application failed", err)
```- The method parameters don't have a sort. You just need to pass them to the method:
```go
logger.Fatal(err, "Application failed")
```- Create a simple error log:
```go
logger.Error(err)
```- Create an error log with a message:
```go
logger.Error("Failed to initialize API", err)
```- Create an error log, with error, message, and params:
```
p := logger.Params{
"platform": handle,
"coin": platform.Coin(),
}
err := platform.Init()
if err != nil {
logger.Error("Failed to initialize API", err, p)
}
```- Debug log:
```go
logger.Debug("Loading Observer API")
// OR
logger.Debug("Loading Observer API", logger.Params{"bind": bind})
```- Warning log:
```go
logger.Warn("Warning", err)
// OR
logger.Warn(err, "Warning")
// OR
logger.Warn("Warning", err, logger.Params{"bind": bind})
```