log: return logger on Init
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
leo 2023-04-28 22:54:09 +02:00
parent 3cb2da457e
commit 269c63c661
Signed by: wanderer
SSH Key Fingerprint: SHA256:Dp8+iwKHSlrMEHzE3bJnPng70I7LEsa3IJXRH/U+idQ
2 changed files with 3 additions and 11 deletions

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) {