-
Notifications
You must be signed in to change notification settings - Fork 1
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
41 changed files
with
1,389 additions
and
69 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
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
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
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,54 +1,54 @@ | ||
// The Simple Logging Facade for Go provides an easy access who everyone who | ||
// wants to log something and do not want to care how it is logged and gives | ||
// others the possibility to implement their own loggers in easy way. | ||
// Package log is the Simple Logging Facade for Go provides an easy access who | ||
// everyone who wants to log something and do not want to care how it is logged | ||
// and gives others the possibility to implement their own loggers in easy way. | ||
// | ||
// Usage | ||
// # Usage | ||
// | ||
// There are 2 common ways to use this framework. | ||
// | ||
// 1. By getting a logger for your current package. This is the most common way | ||
// and is quite clean for one package. If the package contains too many logic | ||
// it might worth it to use the 2nd approach (see below). | ||
// | ||
// package foo | ||
// package foo | ||
// | ||
// import "github.com/echocat/slf4g" | ||
// import "github.com/echocat/slf4g" | ||
// | ||
// var logger = log.GetLoggerForCurrentPackage() | ||
// var logger = log.GetLoggerForCurrentPackage() | ||
// | ||
// func sayHello() { | ||
// // will log with logger="github.com/user/foo" | ||
// logger.Info("Hello, world!") | ||
// } | ||
// func sayHello() { | ||
// // will log with logger="github.com/user/foo" | ||
// logger.Info("Hello, world!") | ||
// } | ||
// | ||
// 2. By getting a logger for the object the logger is for. This is the most | ||
// clean approach and will give you later the maximum flexibility and control. | ||
// | ||
// package foo | ||
// package foo | ||
// | ||
// import "github.com/echocat/slf4g" | ||
// import "github.com/echocat/slf4g" | ||
// | ||
// var logger = log.GetLogger(myType{}) | ||
// var logger = log.GetLogger(myType{}) | ||
// | ||
// type myType struct { | ||
// ... | ||
// } | ||
// type myType struct { | ||
// ... | ||
// } | ||
// | ||
// func (mt myType) sayHello() { | ||
// // will log with logger="github.com/user/foo.myType" | ||
// logger.Info("Hello, world!") | ||
// } | ||
// func (mt myType) sayHello() { | ||
// // will log with logger="github.com/user/foo.myType" | ||
// logger.Info("Hello, world!") | ||
// } | ||
// | ||
// 3. By using the global packages methods which is quite equal to how the SDK | ||
// base logger works. This is only recommend for small application and not for | ||
// libraries you like to export. | ||
// | ||
// package foo | ||
// package foo | ||
// | ||
// import "github.com/echocat/slf4g" | ||
// import "github.com/echocat/slf4g" | ||
// | ||
// func sayHello() { | ||
// // will log with logger=ROOT | ||
// log.Info("Hello, world!") | ||
// } | ||
// func sayHello() { | ||
// // will log with logger=ROOT | ||
// log.Info("Hello, world!") | ||
// } | ||
package log |
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
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,3 +1,4 @@ | ||
//go:build !mock && appengine | ||
// +build !mock,appengine | ||
|
||
package color | ||
|
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
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,3 +1,4 @@ | ||
//go:build mock | ||
// +build mock | ||
|
||
package color | ||
|
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,3 +1,4 @@ | ||
//go:build (!mock && js) || nacl || plan9 | ||
// +build !mock,js nacl plan9 | ||
|
||
package color | ||
|
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
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,3 +1,4 @@ | ||
//go:build !mock | ||
// +build !mock | ||
|
||
package color | ||
|
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,3 +1,4 @@ | ||
//go:build (!mock && linux) || aix | ||
// +build !mock,linux aix | ||
|
||
package color | ||
|
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,3 +1,4 @@ | ||
//go:build !mock | ||
// +build !mock | ||
|
||
package color | ||
|
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,3 +1,4 @@ | ||
//go:build mock | ||
// +build mock | ||
|
||
package color | ||
|
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,33 +1,35 @@ | ||
// This is the reference implementation of a logger of the slf4g framework | ||
// Package native holds the reference implementation of a logger of the slf4g framework | ||
// (https://github.com/echocat/slf4g). | ||
// | ||
// Usage | ||
// # Usage | ||
// | ||
// For the most common cases it is fully enough to anonymously import this | ||
// package in your main.go; nothing more is needed. | ||
// | ||
// github.com/foo/bar/main/main.go: | ||
// package main | ||
// | ||
// import ( | ||
// "github.com/foo/bar" | ||
// _ "github.com/echocat/slf4g/native" | ||
// ) | ||
// package main | ||
// | ||
// func main() { | ||
// bar.SayHello() | ||
// } | ||
// import ( | ||
// "github.com/foo/bar" | ||
// _ "github.com/echocat/slf4g/native" | ||
// ) | ||
// | ||
// func main() { | ||
// bar.SayHello() | ||
// } | ||
// | ||
// github.com/foo/bar/bar.go: | ||
// package bar | ||
// | ||
// import ( | ||
// "github.com/echocat/slf4g" | ||
// ) | ||
// package bar | ||
// | ||
// import ( | ||
// "github.com/echocat/slf4g" | ||
// ) | ||
// | ||
// func SayHello() { | ||
// log.Info("Hello, world!") | ||
// } | ||
// func SayHello() { | ||
// log.Info("Hello, world!") | ||
// } | ||
// | ||
// See more useful stuff in the examples sections. | ||
package native |
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
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
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
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
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
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,15 +1,15 @@ | ||
// Package sdk/bridge provides methods to either hook into the SDK logger itself | ||
// or create compatible instances. | ||
// | ||
// Hooks | ||
// # Hooks | ||
// | ||
// The simples way is to simply anonymously import the hook package to configure | ||
// the whole application to use the slf4g framework on any usage of the SDK | ||
// based loggers. | ||
// | ||
// import ( | ||
// _ "github.com/echocat/slf4g/sdk/bridge/hook" | ||
// ) | ||
// import ( | ||
// _ "github.com/echocat/slf4g/sdk/bridge/hook" | ||
// ) | ||
// | ||
// For manual hooks please see the examples. | ||
package sdk |
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,7 +1,7 @@ | ||
// Importing this package anonymously will configure the whole application to | ||
// use the slf4g framework on any usage of the SDK based loggers. | ||
// | ||
// import ( | ||
// _ "github.com/echocat/slf4g/sdk/bridge/hook" | ||
// ) | ||
// import ( | ||
// _ "github.com/echocat/slf4g/sdk/bridge/hook" | ||
// ) | ||
package hook |
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
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
[![PkgGoDev](https://pkg.go.dev/badge/github.com/echocat/slf4g/sdk/testlog)](https://pkg.go.dev/github.com/echocat/slf4g/sdk/testlog) | ||
|
||
# slf4g testing Logger implementation | ||
|
||
Provides a Logger which will be connected to [`testing.T.Log()`](https://pkg.go.dev/testing#T.Log) of the go SDK. | ||
|
||
If you're looking for an instance to record all logged events see [`github.com/echocat/slf4g/testing/recording`](../../testing/recording) package. | ||
|
||
## Usage | ||
|
||
The easiest way to enable the slf4g framework in your tests is, simply: | ||
|
||
```golang | ||
package foo | ||
|
||
import ( | ||
"testing" | ||
"github.com/echocat/slf4g" | ||
"github.com/echocat/slf4g/sdk/testlog" | ||
) | ||
|
||
func TestMyGreatStuff(t *testing.T) { | ||
testlog.Hook(t) | ||
|
||
log.Info("Yeah! This is a log!") | ||
} | ||
``` | ||
|
||
... that's it! | ||
|
||
See [`Hook(..)`](hook.go) for more details. |
Oops, something went wrong.