latest
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-12-09 19:26:55 +01:00
parent cbe9fca1c6
commit 3519389a80
8 changed files with 128 additions and 35 deletions

View File

@@ -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...)
}

View File

@@ -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)
}