-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
45 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,75 @@ | ||
# adaptlog [![alt text](https://godoc.org/github.com/mantzas/adaptlog?status.png)](https://godoc.org/github.com/mantzas/adaptlog) [![build status](https://img.shields.io/travis/mantzas/adaptlog.svg)](http://travis-ci.org/mantzas/adaptlog) [![Coverage Status](https://coveralls.io/repos/github/mantzas/adaptlog/badge.svg?branch=master)](https://coveralls.io/github/mantzas/adaptlog?branch=master) | ||
|
||
|
||
Package adaptlog is a logging abstraction for go. The name of the package is a composition of adapt(adaptive) and log(logging). | ||
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 in order to avoid depending on a specific logging implementation. | ||
The package provides a abstraction that covers the standard logging(like in the standard log package) and the leveled logging (like many of them out there). | ||
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 the Logger interface like illustarted in the samples of the examples folder. | ||
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" | ||
"log" | ||
|
||
"github.com/mantzas/adaptlog" | ||
) | ||
|
||
// MyLogger custom logger implementing the StdLogger interface | ||
// MyLogger custom logger implementing the Simple Logger interface | ||
type MyLogger struct { | ||
} | ||
|
||
// Print logging | ||
func (l *MyLogger) Print(args ...interface{}) { | ||
log.Print(args...) | ||
log.Print(args...) | ||
} | ||
|
||
// Printf logging | ||
func (l *MyLogger) Printf(msg string, args ...interface{}) { | ||
log.Printf(msg, args...) | ||
log.Printf(msg, args...) | ||
} | ||
|
||
// Println logging | ||
func (l *MyLogger) Println(args ...interface{}) { | ||
log.Println(args...) | ||
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.Configure(new(MyLogger), adaptlog.AnyLevel) | ||
// configure once | ||
adaptlog.ConfigureSimpleLogger(new(MyLogger)) | ||
|
||
// use logger | ||
adaptlog.Print("Hello World!") | ||
// use logger | ||
adaptlog.Simple.Print("Hello World!") | ||
} |