This commit is contained in:
@@ -2,14 +2,10 @@ package bork
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrMissingMagic = errors.New("missing magic bytes in file")
|
||||
ErrFileTruncated = errors.New("file/stream is truncated abnormally")
|
||||
ErrFileIntegrity = errors.New("file/stream checksum failure")
|
||||
)
|
||||
|
||||
func Newf(format string, args ...interface{}) error {
|
||||
return fmt.Errorf(format, args...)
|
||||
}
|
||||
|
||||
@@ -23,11 +23,20 @@ func DisableStyling() {
|
||||
pterm.Fatal.Prefix.Text = ""
|
||||
}
|
||||
|
||||
var TestingTraces bool = false
|
||||
|
||||
func Init() {
|
||||
log.SetHandler(acli.Default)
|
||||
log.SetLevel(log.InfoLevel)
|
||||
}
|
||||
|
||||
func Tracef(format string, args ...interface{}) {
|
||||
if !TestingTraces {
|
||||
return
|
||||
}
|
||||
DebugReal(fmt.Sprintf(format, args...), 2)
|
||||
}
|
||||
|
||||
func Debugf(format string, args ...interface{}) {
|
||||
DebugReal(fmt.Sprintf(format, args...), 2)
|
||||
}
|
||||
@@ -45,10 +54,22 @@ func DebugReal(arg string, cs int) {
|
||||
log.Debug(tag + arg)
|
||||
}
|
||||
|
||||
func TraceDump(args ...interface{}) {
|
||||
if !TestingTraces {
|
||||
return
|
||||
}
|
||||
DebugReal(spew.Sdump(args...), 2)
|
||||
}
|
||||
|
||||
func Dump(args ...interface{}) {
|
||||
DebugReal(spew.Sdump(args...), 2)
|
||||
}
|
||||
|
||||
func EnableTestingLogging() {
|
||||
TestingTraces = true
|
||||
EnableDebugLogging()
|
||||
}
|
||||
|
||||
func EnableDebugLogging() {
|
||||
SetLevel(log.DebugLevel)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user