Archived
1
This repository has been archived on 2022-11-04. You can view files and clone it, but cannot push or open issues or pull requests.
fwzookeeper/vendor/github.com/kirillDanshin/dlog/buffered_enabled.go

50 lines
785 B
Go
Raw Normal View History

2018-12-22 17:38:56 +04:00
// +build debug
package dlog
import "fmt"
// Ln is a build-time enabled println
func (b *Buffered) Ln(v ...interface{}) {
b.prepare()
b.Lock()
fmt.Fprintln(b.bb, v...)
b.Unlock()
}
// P is a build-time enabled print
func (b *Buffered) P(v ...interface{}) {
b.prepare()
b.Lock()
fmt.Fprint(b.bb, v...)
b.Unlock()
}
// F is a build-time enabled printf
func (b *Buffered) F(f string, v ...interface{}) {
b.prepare()
b.Lock()
fmt.Fprintf(b.bb, f+"\n", v...)
b.Unlock()
}
// D dumps a value
func (b *Buffered) D(v ...interface{}) {
b.prepare()
b.Lock()
for _, v := range v {
fmt.Fprintf(b.bb, "%+#v\n", v)
}
b.Unlock()
}
func (b *Buffered) prepare() {
if b.bb == nil {
b = NewBuffered()
}
}
func (b *Buffered) String() string {
return string(b.bb.Bytes())
}