MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / Init

Function Init

logger/logger.go:25–46  ·  view source on GitHub ↗

Init creates a logger and sets it as the default log/slog logger

(config *Config)

Source from the content-addressed store, hash-verified

23
24// Init creates a logger and sets it as the default log/slog logger
25func Init(config *Config) error {
26 if err := config.Validate(); err != nil {
27 return err
28 }
29
30 handler = NewHandler(os.Stdout, config)
31 setDefaultHandler(handler)
32
33 gliblog.Init()
34
35 if config.Syslog.Enabled {
36 slHook, err := syslog.NewHook(&config.Syslog)
37 if err != nil {
38 return fmt.Errorf("unable to connect to syslog daemon: %w", err)
39 }
40 if slHook != nil {
41 AddHook(slHook)
42 }
43 }
44
45 return nil
46}
47
48func AddHook(hook Hook) {
49 if handler != nil {

Callers 1

InitFunction · 0.92

Calls 7

InitFunction · 0.92
NewHookFunction · 0.92
NewHandlerFunction · 0.85
setDefaultHandlerFunction · 0.85
AddHookFunction · 0.85
ErrorfMethod · 0.80
ValidateMethod · 0.45

Tested by

no test coverage detected