https://github.com/mantzas/adaptlog
Logging adapter
https://github.com/mantzas/adaptlog
go golang logging
Last synced: 5 months ago
JSON representation
Logging adapter
- Host: GitHub
- URL: https://github.com/mantzas/adaptlog
- Owner: mantzas
- License: apache-2.0
- Created: 2016-01-14T13:39:55.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-03-02T19:34:21.000Z (over 8 years ago)
- Last Synced: 2025-10-29T21:04:20.660Z (8 months ago)
- Topics: go, golang, logging
- Language: Go
- Size: 43.9 KB
- Stars: 9
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# adaptlog [](https://godoc.org/github.com/mantzas/adaptlog) [](http://travis-ci.org/mantzas/adaptlog) [](https://coveralls.io/github/mantzas/adaptlog?branch=master) [](https://goreportcard.com/report/github.com/mantzas/adaptlog)
Package adaptlog is a logging abstraction in go. The name of the package is a composition of adapt(adaptive) and log(logging).
The developer uses this abstraction to avoid depending on a specific logging implementation.
The package provides an abstraction that covers the standard logging(like in the standard log package) and the leveled logging (like many of them out there).
The simplest way to use adaptlog's logger is by simply implementing a Logger interface like illustrated in the samples of the examples folder.
package main
import (
"log"
"github.com/mantzas/adaptlog"
)
// MyLogger custom logger implementing the Simple Logger interface
type MyLogger struct {
}
// Print logging
func (l *MyLogger) Print(args ...interface{}) {
log.Print(args...)
}
// Printf logging
func (l *MyLogger) Printf(msg string, args ...interface{}) {
log.Printf(msg, args...)
}
// Println logging
func (l *MyLogger) Println(args ...interface{}) {
log.Println(args...)
}
// Panic logging
func (l *MyLogger) Panic(args ...interface{}) {
log.Panic(args...)
}
// Panicf logging
func (l *MyLogger) Panicf(msg string, args ...interface{}) {
log.Panicf(msg, args...)
}
// Panicln logging
func (l *MyLogger) Panicln(args ...interface{}) {
log.Panicln(args...)
}
// Fatal logging
func (l *MyLogger) Fatal(args ...interface{}) {
log.Panic(args...)
}
// Fatalf logging
func (l *MyLogger) Fatalf(msg string, args ...interface{}) {
log.Panicf(msg, args...)
}
// Fatalln logging
func (l *MyLogger) Fatalln(args ...interface{}) {
log.Panicln(args...)
}
func main() {
// configure once
adaptlog.ConfigureSimpleLogger(new(MyLogger))
// use logger
adaptlog.Simple.Print("Hello World!")
}