log: output caller on debug, use stdout as default

This commit is contained in:
decentral1se 2024-07-08 00:39:27 +02:00
parent 050a479df7
commit cde06f4f00
Signed by: decentral1se
GPG Key ID: 03789458B3D0C410
3 changed files with 18 additions and 14 deletions

View File

@ -17,6 +17,7 @@ import (
"coopcloud.tech/abra/pkg/config"
"coopcloud.tech/abra/pkg/log"
"coopcloud.tech/abra/pkg/web"
charmLog "github.com/charmbracelet/log"
"github.com/urfave/cli"
)
@ -183,6 +184,7 @@ func newAbraApp(version, commit string) *cli.App {
}
}
charmLog.SetDefault(log.Logger)
log.Debugf("abra version %s, commit %s", version, commit)
return nil

View File

@ -289,6 +289,7 @@ func SubCommandBefore(c *cli.Context) error {
if Debug {
log.SetLevel(log.DebugLevel)
log.SetOutput(os.Stderr)
log.SetReportCaller(true)
}
return nil

View File

@ -7,27 +7,28 @@ import (
charmLog "github.com/charmbracelet/log"
)
// Log is the central logging interface.
var log = charmLog.NewWithOptions(os.Stderr, charmLog.Options{
ReportCaller: true,
// Logger is the central logging interface.
var Logger = charmLog.NewWithOptions(os.Stdout, charmLog.Options{
ReportCaller: false,
ReportTimestamp: false,
})
var Fatal = log.Fatal
var Fatalf = log.Fatalf
var Fatal = Logger.Fatal
var Fatalf = Logger.Fatalf
var Debug = log.Debug
var Debugf = log.Debugf
var Debug = Logger.Debug
var Debugf = Logger.Debugf
var Info = log.Info
var Infof = log.Infof
var Info = Logger.Info
var Infof = Logger.Infof
var Warn = log.Warn
var Warnf = log.Warnf
var Warn = Logger.Warn
var Warnf = Logger.Warnf
var Error = log.Error
var Errorf = log.Errorf
var Error = Logger.Error
var Errorf = Logger.Errorf
var SetLevel = log.SetLevel
var SetLevel = Logger.SetLevel
var DebugLevel = charmLog.DebugLevel
var SetOutput = charmLog.SetOutput
var SetReportCaller = charmLog.SetReportCaller