log: return logger on Init
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
3cb2da457e
commit
269c63c661
10
run.go
10
run.go
@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"net/http"
|
||||
@ -56,8 +55,6 @@ var (
|
||||
license = flag.Bool("license", false, "Print licensing information and exit")
|
||||
version = "dev"
|
||||
log *slogging.Logger
|
||||
|
||||
ErrCouldNotInitialiseLogger = errors.New("Could not initialise logger")
|
||||
)
|
||||
|
||||
func run() error {
|
||||
@ -70,12 +67,7 @@ func run() error {
|
||||
|
||||
printHeader()
|
||||
|
||||
err := slogging.Init(true)
|
||||
if err != nil {
|
||||
return ErrCouldNotInitialiseLogger
|
||||
}
|
||||
|
||||
log = slogging.GetLogger()
|
||||
log = slogging.Init(true)
|
||||
|
||||
// TODO: allow different configuration formats (toml, ni)
|
||||
// TODO: rename main.go to pcmt.go
|
||||
|
@ -17,7 +17,7 @@ func GetLogger() *Logger {
|
||||
return logger
|
||||
}
|
||||
|
||||
func Init(jsonHandler bool) error {
|
||||
func Init(jsonHandler bool) *Logger {
|
||||
if jsonHandler {
|
||||
logger = &Logger{slog.New(slog.NewJSONHandler(os.Stderr))}
|
||||
} else {
|
||||
@ -26,7 +26,7 @@ func Init(jsonHandler bool) error {
|
||||
|
||||
logger.Info("slog logger initialised")
|
||||
|
||||
return nil
|
||||
return logger
|
||||
}
|
||||
|
||||
func (l *Logger) Infof(msg string, args ...any) {
|
||||
|
Loading…
Reference in New Issue
Block a user