stream: write error to stderr instead

This commit is contained in:
Vincent Batts 2015-08-16 19:12:32 -04:00
parent a03956b35e
commit 499faa7234
1 changed files with 5 additions and 4 deletions

View File

@ -1,8 +1,9 @@
package merkle package merkle
import ( import (
"fmt"
"hash" "hash"
"log" "os"
"runtime" "runtime"
) )
@ -102,7 +103,7 @@ func (mh *merkleHash) Sum(b []byte) []byte {
// :-\ // :-\
sBuf := make([]byte, 1024) sBuf := make([]byte, 1024)
runtime.Stack(sBuf, false) runtime.Stack(sBuf, false)
log.Printf("[ERROR]: %s %q", err, string(sBuf)) fmt.Fprintf(os.Stderr, "[ERROR]: %s %q", err, string(sBuf))
return nil return nil
} }
mh.tree.Nodes = append(mh.tree.Nodes, n) mh.tree.Nodes = append(mh.tree.Nodes, n)
@ -117,7 +118,7 @@ func (mh *merkleHash) Sum(b []byte) []byte {
if err != nil { if err != nil {
sBuf := make([]byte, 1024) sBuf := make([]byte, 1024)
runtime.Stack(sBuf, false) runtime.Stack(sBuf, false)
log.Printf("[ERROR]: %s %q", err, string(sBuf)) fmt.Fprintf(os.Stderr, "[ERROR]: %s %q", err, string(sBuf))
return nil return nil
} }
mh.tree.Nodes = append(mh.tree.Nodes, n) mh.tree.Nodes = append(mh.tree.Nodes, n)
@ -130,7 +131,7 @@ func (mh *merkleHash) Sum(b []byte) []byte {
// :-\ // :-\
sBuf := make([]byte, 1024) sBuf := make([]byte, 1024)
runtime.Stack(sBuf, false) runtime.Stack(sBuf, false)
log.Printf("[ERROR]: %s %q", err, string(sBuf)) fmt.Fprintf(os.Stderr, "[ERROR]: %s %q", err, string(sBuf))
return nil return nil
} }
return sum return sum