|
@@ -12,6 +12,7 @@ type Output struct {
|
|
|
sync.Mutex
|
|
|
dests []io.Writer
|
|
|
tasks sync.WaitGroup
|
|
|
+ used bool
|
|
|
}
|
|
|
|
|
|
// NewOutput returns a new Output object with no destinations attached.
|
|
@@ -20,6 +21,13 @@ func NewOutput() *Output {
|
|
|
return &Output{}
|
|
|
}
|
|
|
|
|
|
+// Return true if something was written on this output
|
|
|
+func (o *Output) Used() bool {
|
|
|
+ o.Mutex.Lock()
|
|
|
+ defer o.Mutex.Unlock()
|
|
|
+ return o.used
|
|
|
+}
|
|
|
+
|
|
|
// Add attaches a new destination to the Output. Any data subsequently written
|
|
|
// to the output will be written to the new destination in addition to all the others.
|
|
|
// This method is thread-safe.
|
|
@@ -82,6 +90,7 @@ func (o *Output) AddString(dst *string) error {
|
|
|
func (o *Output) Write(p []byte) (n int, err error) {
|
|
|
o.Mutex.Lock()
|
|
|
defer o.Mutex.Unlock()
|
|
|
+ o.used = true
|
|
|
var firstErr error
|
|
|
for _, dst := range o.dests {
|
|
|
_, err := dst.Write(p)
|