Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

log adapter to nuveo/log

License

NotificationsYou must be signed in to change notification settings

arxdsilva/logAdapter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

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

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp