mirror of
https://github.com/vbatts/go-mtree.git
synced 2024-11-22 08:25:38 +00:00
Vincent Batts
fc5450ed71
This allows for restoring some attributes of files from the state in an mtree Manifest Reported-by: Matthew Garrett <Matthewgarrett@google.com> Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
26 lines
711 B
Go
26 lines
711 B
Go
package mtree
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"time"
|
|
)
|
|
|
|
// DebugOutput is the where DEBUG output is written
|
|
var DebugOutput = os.Stderr
|
|
|
|
// Debugln writes output to DebugOutput, only if DEBUG environment variable is set
|
|
func Debugln(a ...interface{}) (n int, err error) {
|
|
if os.Getenv("DEBUG") != "" {
|
|
return fmt.Fprintf(DebugOutput, "[%d] [DEBUG] %s\n", time.Now().UnixNano(), a)
|
|
}
|
|
return 0, nil
|
|
}
|
|
|
|
// Debugf writes 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
|
|
}
|