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 (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -56,8 +55,6 @@ var (
|
|||||||
license = flag.Bool("license", false, "Print licensing information and exit")
|
license = flag.Bool("license", false, "Print licensing information and exit")
|
||||||
version = "dev"
|
version = "dev"
|
||||||
log *slogging.Logger
|
log *slogging.Logger
|
||||||
|
|
||||||
ErrCouldNotInitialiseLogger = errors.New("Could not initialise logger")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func run() error {
|
func run() error {
|
||||||
@ -70,12 +67,7 @@ func run() error {
|
|||||||
|
|
||||||
printHeader()
|
printHeader()
|
||||||
|
|
||||||
err := slogging.Init(true)
|
log = slogging.Init(true)
|
||||||
if err != nil {
|
|
||||||
return ErrCouldNotInitialiseLogger
|
|
||||||
}
|
|
||||||
|
|
||||||
log = slogging.GetLogger()
|
|
||||||
|
|
||||||
// TODO: allow different configuration formats (toml, ni)
|
// TODO: allow different configuration formats (toml, ni)
|
||||||
// TODO: rename main.go to pcmt.go
|
// TODO: rename main.go to pcmt.go
|
||||||
|
@ -17,7 +17,7 @@ func GetLogger() *Logger {
|
|||||||
return logger
|
return logger
|
||||||
}
|
}
|
||||||
|
|
||||||
func Init(jsonHandler bool) error {
|
func Init(jsonHandler bool) *Logger {
|
||||||
if jsonHandler {
|
if jsonHandler {
|
||||||
logger = &Logger{slog.New(slog.NewJSONHandler(os.Stderr))}
|
logger = &Logger{slog.New(slog.NewJSONHandler(os.Stderr))}
|
||||||
} else {
|
} else {
|
||||||
@ -26,7 +26,7 @@ func Init(jsonHandler bool) error {
|
|||||||
|
|
||||||
logger.Info("slog logger initialised")
|
logger.Info("slog logger initialised")
|
||||||
|
|
||||||
return nil
|
return logger
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *Logger) Infof(msg string, args ...any) {
|
func (l *Logger) Infof(msg string, args ...any) {
|
||||||
|
Loading…
Reference in New Issue
Block a user