- Notifications
You must be signed in to change notification settings - Fork0
arxdsilva/logAdapter
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This repo is a adapter to the packagenuveo/log that uses Golang's standardlog
instead offmt
package to write into stdout. This is useful for testing if a application logged something by setting the log to a buffer.
package mainimport ("bytes""fmt""io""os""testing" l"log""github.com/nuveo/log" la"github.com/arxdsilva/logAdapter")funcreadByte() {// force an errorerr:=io.EOFiferr!=nil {log.Println("Couldn't read first byte") }}funcTestReadByte(t*testing.T) {// remove std adapter// this prevents double logginglog.RemoveAdapter("stdout")log.AddAdapter("adapter", log.AdapterPod{Adapter:la.LogAdapter,Config:nil})varbuf bytes.Bufferl.SetOutput(&buf)deferfunc() {l.SetOutput(os.Stderr) }()readByte()// do something with the logst.Log(buf.String())}
About
log adapter to nuveo/log
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
No releases published
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.