updated to use bun and updated hws modules.
This commit is contained in:
36
internal/config/logger.go
Normal file
36
internal/config/logger.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"git.haelnorr.com/h/golib/env"
|
||||
"git.haelnorr.com/h/golib/hlog"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type HLOGConfig struct {
|
||||
// ENV LOG_LEVEL: Log level for global logging. (default: info)
|
||||
LogLevel hlog.Level
|
||||
|
||||
// ENV LOG_OUTPUT: Output method for the logger. (default: console)
|
||||
// Valid options: "file", "console", "both"
|
||||
LogOutput string
|
||||
|
||||
// ENV LOG_DIR: Path to create log files
|
||||
LogDir string
|
||||
}
|
||||
|
||||
func setupHLOG() (*HLOGConfig, error) {
|
||||
logLevel, err := hlog.LogLevel(env.String("LOG_LEVEL", "info"))
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "hlog.LogLevel")
|
||||
}
|
||||
logOutput := env.String("LOG_OUTPUT", "console")
|
||||
if logOutput != "both" && logOutput != "console" && logOutput != "file" {
|
||||
return nil, errors.Errorf("Invalid LOG_OUTPUT: %s", logOutput)
|
||||
}
|
||||
cfg := &HLOGConfig{
|
||||
LogLevel: logLevel,
|
||||
LogOutput: logOutput,
|
||||
LogDir: env.String("LOG_DIR", ""),
|
||||
}
|
||||
return cfg, nil
|
||||
}
|
||||
Reference in New Issue
Block a user