mirror of
https://github.com/Fishwaldo/go-logadapter.git
synced 2025-07-06 21:08:40 +00:00
Add Example Function
This commit is contained in:
parent
154ebc43a1
commit
b1285e8b78
1 changed files with 31 additions and 0 deletions
31
logadapter_test.go
Normal file
31
logadapter_test.go
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
package logadapter_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/Fishwaldo/go-logadapter"
|
||||||
|
)
|
||||||
|
|
||||||
|
type TestStruct struct {
|
||||||
|
Logger logadapter.Logger
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TestStruct) Init() {
|
||||||
|
temp := logadapter.DefaultLogger()
|
||||||
|
temp.SetLevel(logadapter.LOG_TRACE)
|
||||||
|
t.Logger = temp
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TestStruct) LogSomething() {
|
||||||
|
t.Logger.Info("This is a message")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TestStruct) StructuredLog() {
|
||||||
|
t.Logger.With("Test", "Message").Trace("Hello %s", string("world"))
|
||||||
|
}
|
||||||
|
|
||||||
|
func Example() {
|
||||||
|
ts := TestStruct{}
|
||||||
|
ts.Init()
|
||||||
|
ts.LogSomething()
|
||||||
|
ts.StructuredLog()
|
||||||
|
ts.Logger.Warn("This is outside the Structure")
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue