mirror of
https://github.com/stashapp/stash.git
synced 2025-12-15 04:44:28 +01:00
* Upgrade gqlgen to v0.17.2 This enables builds on Go 1.18. github.com/vektah/gqlparser is upgraded to the newest version too. Getting this to work is a bit of a hazzle. I had to first remove vendoring from the repository, perform the upgrade and then re-introduce the vendor directory. I think gqlgens analysis went wrong for some reason on the upgrade. It would seem a clean-room installation fixed it. * Bump project to 1.18 * Update all packages, address gqlgenc breaking changes * Let `go mod tidy` handle the go.mod file * Upgrade linter to 1.45.2 * Introduce v1.45.2 of the linter The linter now correctly warns on `strings.Title` because it isn't unicode-aware. Fix this by using the suggested fix from x/text/cases to produce unicode-aware strings. The mapping isn't entirely 1-1 as this new approach has a larger iface: it spans all of unicode rather than just ASCII. It coincides for ASCII however, so things should be largely the same. * Ready ourselves for errchkjson and contextcheck. * Revert dockerfile golang version changes for now Co-authored-by: Kermie <kermie@isinthe.house> Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
77 lines
2 KiB
Go
77 lines
2 KiB
Go
package viper
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
jww "github.com/spf13/jwalterweatherman"
|
|
)
|
|
|
|
// Logger is a unified interface for various logging use cases and practices, including:
|
|
// - leveled logging
|
|
// - structured logging
|
|
type Logger interface {
|
|
// Trace logs a Trace event.
|
|
//
|
|
// Even more fine-grained information than Debug events.
|
|
// Loggers not supporting this level should fall back to Debug.
|
|
Trace(msg string, keyvals ...interface{})
|
|
|
|
// Debug logs a Debug event.
|
|
//
|
|
// A verbose series of information events.
|
|
// They are useful when debugging the system.
|
|
Debug(msg string, keyvals ...interface{})
|
|
|
|
// Info logs an Info event.
|
|
//
|
|
// General information about what's happening inside the system.
|
|
Info(msg string, keyvals ...interface{})
|
|
|
|
// Warn logs a Warn(ing) event.
|
|
//
|
|
// Non-critical events that should be looked at.
|
|
Warn(msg string, keyvals ...interface{})
|
|
|
|
// Error logs an Error event.
|
|
//
|
|
// Critical events that require immediate attention.
|
|
// Loggers commonly provide Fatal and Panic levels above Error level,
|
|
// but exiting and panicing is out of scope for a logging library.
|
|
Error(msg string, keyvals ...interface{})
|
|
}
|
|
|
|
type jwwLogger struct{}
|
|
|
|
func (jwwLogger) Trace(msg string, keyvals ...interface{}) {
|
|
jww.TRACE.Printf(jwwLogMessage(msg, keyvals...))
|
|
}
|
|
|
|
func (jwwLogger) Debug(msg string, keyvals ...interface{}) {
|
|
jww.DEBUG.Printf(jwwLogMessage(msg, keyvals...))
|
|
}
|
|
|
|
func (jwwLogger) Info(msg string, keyvals ...interface{}) {
|
|
jww.INFO.Printf(jwwLogMessage(msg, keyvals...))
|
|
}
|
|
|
|
func (jwwLogger) Warn(msg string, keyvals ...interface{}) {
|
|
jww.WARN.Printf(jwwLogMessage(msg, keyvals...))
|
|
}
|
|
|
|
func (jwwLogger) Error(msg string, keyvals ...interface{}) {
|
|
jww.ERROR.Printf(jwwLogMessage(msg, keyvals...))
|
|
}
|
|
|
|
func jwwLogMessage(msg string, keyvals ...interface{}) string {
|
|
out := msg
|
|
|
|
if len(keyvals) > 0 && len(keyvals)%2 == 1 {
|
|
keyvals = append(keyvals, nil)
|
|
}
|
|
|
|
for i := 0; i <= len(keyvals)-2; i += 2 {
|
|
out = fmt.Sprintf("%s %v=%v", out, keyvals[i], keyvals[i+1])
|
|
}
|
|
|
|
return out
|
|
}
|