24 lines
276 B
Go
24 lines
276 B
Go
|
package zlog
|
||
|
|
||
|
import (
|
||
|
"io"
|
||
|
"sync"
|
||
|
)
|
||
|
|
||
|
type WriteLocker interface {
|
||
|
io.Writer
|
||
|
sync.Locker
|
||
|
}
|
||
|
|
||
|
func WrapLocker(w io.Writer) WriteLocker {
|
||
|
if wl, ok := w.(WriteLocker); ok {
|
||
|
return wl
|
||
|
}
|
||
|
return &writeLocker{Writer: w}
|
||
|
}
|
||
|
|
||
|
type writeLocker struct {
|
||
|
io.Writer
|
||
|
sync.Mutex
|
||
|
}
|