getting warmer

This commit is contained in:
2022-12-06 20:42:26 +04:00
parent b0c16462c4
commit 86d724ee35
6 changed files with 146 additions and 19 deletions

13
internal/bork/error.go Normal file
View File

@@ -0,0 +1,13 @@
package bork
import (
"errors"
"fmt"
)
var ErrMissingMagic = errors.New("missing magic bytes in file")
var ErrFileTruncated = errors.New("file/stream is truncated abnormally")
func Newf(format string, args ...interface{}) error {
return errors.New(fmt.Sprintf(format, args...))
}

View File

@@ -1,6 +1,9 @@
package log
import (
"fmt"
"runtime"
"github.com/apex/log"
acli "github.com/apex/log/handlers/cli"
"github.com/davecgh/go-spew/spew"
@@ -25,13 +28,25 @@ func Init() {
log.SetLevel(log.InfoLevel)
}
func Debugf(format string, args ...interface{}) {
DebugReal(fmt.Sprintf(format, args...), 2)
}
func Debug(arg string) {
log.Debug(arg)
DebugReal(arg, 2)
}
func DebugReal(arg string, cs int) {
_, callerFile, callerLine, ok := runtime.Caller(cs)
if !ok {
return
}
tag := fmt.Sprintf("%s:%d: ", callerFile, callerLine)
log.Debug(tag + arg)
}
func Dump(args ...interface{}) {
str := spew.Sdump(args...)
Debug(str)
DebugReal(spew.Sdump(args...), 2)
}
func EnableDebugLogging() {