mirror of
https://github.com/vbatts/tar-split.git
synced 2025-10-04 13:11:01 +00:00
debug: add an mtree.Debugf and -debug flag
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
39f68f5be2
commit
ed6b293839
4 changed files with 26 additions and 3 deletions
18
debug.go
Normal file
18
debug.go
Normal file
|
@ -0,0 +1,18 @@
|
|||
package mtree
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
// DebugOutput is the where DEBUG output is written
|
||||
var DebugOutput = os.Stderr
|
||||
|
||||
// Debugf does formatted output to DebugOutput, only if DEBUG environment variable is set
|
||||
func Debugf(format string, a ...interface{}) (n int, err error) {
|
||||
if os.Getenv("DEBUG") != "" {
|
||||
return fmt.Fprintf(DebugOutput, "[%d] [DEBUG] %s\n", time.Now().UnixNano(), fmt.Sprintf(format, a...))
|
||||
}
|
||||
return 0, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue