|
@@ -23,8 +23,8 @@ func NewOutput() *Output {
|
|
|
|
|
|
// Return true if something was written on this output
|
|
|
func (o *Output) Used() bool {
|
|
|
- o.Mutex.Lock()
|
|
|
- defer o.Mutex.Unlock()
|
|
|
+ o.Lock()
|
|
|
+ defer o.Unlock()
|
|
|
return o.used
|
|
|
}
|
|
|
|
|
@@ -32,8 +32,8 @@ func (o *Output) Used() bool {
|
|
|
// to the output will be written to the new destination in addition to all the others.
|
|
|
// This method is thread-safe.
|
|
|
func (o *Output) Add(dst io.Writer) {
|
|
|
- o.Mutex.Lock()
|
|
|
- defer o.Mutex.Unlock()
|
|
|
+ o.Lock()
|
|
|
+ defer o.Unlock()
|
|
|
o.dests = append(o.dests, dst)
|
|
|
}
|
|
|
|
|
@@ -42,8 +42,8 @@ func (o *Output) Add(dst io.Writer) {
|
|
|
// destination in addition to all the others. This method is thread-safe.
|
|
|
func (o *Output) Set(dst io.Writer) {
|
|
|
o.Close()
|
|
|
- o.Mutex.Lock()
|
|
|
- defer o.Mutex.Unlock()
|
|
|
+ o.Lock()
|
|
|
+ defer o.Unlock()
|
|
|
o.dests = []io.Writer{dst}
|
|
|
}
|
|
|
|
|
@@ -96,8 +96,8 @@ func (o *Output) AddString(dst *string) error {
|
|
|
// Write writes the same data to all registered destinations.
|
|
|
// This method is thread-safe.
|
|
|
func (o *Output) Write(p []byte) (n int, err error) {
|
|
|
- o.Mutex.Lock()
|
|
|
- defer o.Mutex.Unlock()
|
|
|
+ o.Lock()
|
|
|
+ defer o.Unlock()
|
|
|
o.used = true
|
|
|
var firstErr error
|
|
|
for _, dst := range o.dests {
|
|
@@ -113,8 +113,8 @@ func (o *Output) Write(p []byte) (n int, err error) {
|
|
|
// AddTail and AddString tasks to complete.
|
|
|
// The Close method of each destination is called if it exists.
|
|
|
func (o *Output) Close() error {
|
|
|
- o.Mutex.Lock()
|
|
|
- defer o.Mutex.Unlock()
|
|
|
+ o.Lock()
|
|
|
+ defer o.Unlock()
|
|
|
var firstErr error
|
|
|
for _, dst := range o.dests {
|
|
|
if closer, ok := dst.(io.WriteCloser); ok {
|