Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/creativeprojects/clog
go console log
https://github.com/creativeprojects/clog
color colour console console-log console-logger go log logger logging logging-framework logging-library unstructured-logs
Last synced: 29 days ago
JSON representation
go console log
- Host: GitHub
- URL: https://github.com/creativeprojects/clog
- Owner: creativeprojects
- License: mit
- Created: 2020-07-12T18:50:15.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-10-30T21:37:41.000Z (about 1 year ago)
- Last Synced: 2024-06-20T19:30:11.722Z (5 months ago)
- Topics: color, colour, console, console-log, console-logger, go, log, logger, logging, logging-framework, logging-library, unstructured-logs
- Language: Go
- Homepage:
- Size: 139 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Godoc reference](https://godoc.org/github.com/creativeprojects/clog?status.svg)](https://pkg.go.dev/github.com/creativeprojects/clog)
![Build](https://github.com/creativeprojects/clog/workflows/Go/badge.svg)
[![Go Report Card](https://goreportcard.com/badge/github.com/creativeprojects/clog)](https://goreportcard.com/report/github.com/creativeprojects/clog)
[![codecov](https://codecov.io/gh/creativeprojects/clog/branch/master/graph/badge.svg?token=N11UE47ESS)](https://codecov.io/gh/creativeprojects/clog)# clog (console-log)
All the fashionable loggers for Go tend to focus on structured logging, and that's perfectly fine: until you simply need a logger for a console application...So here's yet another logger for Go:
- unstructured logging
- console logging in colour
- file logging
- simple to use
- filter your logs from 5 levels of severity (Trace, Debug, Info, Warn, Error)
- redirect your logs to an io.Writer
- get logs coming from an io.Writer
- using the logger from the standard library under the hood
- extensible (via handlers and middleware)
- unit test coverage of more than 90%
- drop-in replacement for the standard library loggerHave a look at the [examples](https://github.com/creativeprojects/clog/tree/master/examples) if you like the look of it
Here's a very simple one:
```go
package mainimport (
"fmt"
"github.com/creativeprojects/clog"
)func main() {
log := clog.NewFilteredConsoleLogger(clog.LevelInfo)log.Info("will be displayed")
log.Debug("will be discarded")
log.Trace("will be discarded")
log.Trace(func() string { return "will not be called" })log.Info(fmt.Sprintf, "generated and displayed(%d)", 1)
log.Infof("generated and displayed(%d)", 2)
}```
Documentation available on [GoDoc](https://pkg.go.dev/github.com/creativeprojects/clog?tab=doc)