https://github.com/hamba/logger
A fast Go logger
https://github.com/hamba/logger
golang logger
Last synced: about 1 year ago
JSON representation
A fast Go logger
- Host: GitHub
- URL: https://github.com/hamba/logger
- Owner: hamba
- License: mit
- Created: 2019-02-11T07:06:39.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2025-03-24T17:12:50.000Z (over 1 year ago)
- Last Synced: 2025-03-27T21:52:12.806Z (over 1 year ago)
- Topics: golang, logger
- Language: Go
- Size: 136 KB
- Stars: 10
- Watchers: 1
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

[](https://goreportcard.com/report/github.com/hamba/logger)
[](https://github.com/hamba/logger/actions)
[](https://coveralls.io/github/hamba/logger?branch=master)
[](https://pkg.go.dev/github.com/hamba/logger/v2)
[](https://github.com/hamba/logger/releases)
[](https://raw.githubusercontent.com/hamba/logger/master/LICENSE)
logger is a fast Go logging package made to be simple but effective.
## Overview
Install with:
```shell
go get github.com/hamba/logger/v2
```
#### Formatters
* **JSON**
* **Logfmt**
* **Console**
#### Writers
* **SyncWriter** Write synchronised to a Writer
**Note:** This project has renamed the default branch from `master` to `main`. You will need to update your local environment.
## Examples
```go
log := logger.New(os.Stdout, logger.LogfmtFormat(), logger.Info)
// Logger can have scoped context
log = log.With(ctx.Str("env", "prod"))
// All messages can have a context
log.Warn("connection error", ctx.Str("redis", "dsn_1"), ctx.Int("timeout", conn.Timeout()))
```
Will log the message
```
lvl=warn msg="connection error" env=prod redis=dsn_1 timeout=0.500
```
More examples can be found in the [godocs](https://godoc.org/github.com/hamba/logger).