Jobs & Workflows https://armen.surge.sh
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

65 lines
1.6 KiB

/*
------------------------------------------------------------------------------------------------------------------------
####### logger ####### Copyright (c) 2021 mls-361 ################################################## MIT License #######
------------------------------------------------------------------------------------------------------------------------
*/
package logger
import (
"os"
"forge.chapril.org/mls-361/logger"
"forge.chapril.org/armen/armen/internal/components"
)
// Build AFAIRE.
func Build(ccs *components.Components) (components.Logger, error) {
app := ccs.Application
cfg := ccs.Config.Logger()
level := cfg.Level
if app.Debug() > 0 {
level = "trace"
}
var (
output logger.Output
err error
)
switch cfg.Output {
case "syslog":
output, err = logger.NewSyslogOutput(cfg.Facility, app.Name())
default:
output = logger.NewStderrOutput()
}
if err != nil {
return nil, err
}
logger, err := logger.New(app.ID(), app.Name(), level, output)
if err != nil {
return nil, err
}
logger.Info( //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
"APP",
"id", app.ID(),
"name", app.Name(),
"version", app.Version(),
"builtAt", app.BuiltAt().Format("2006-01-02 15:04:05"),
"pid", os.Getpid(),
)
logger.Debug("Config", "data", ccs.Config.Data().String()) //:::::::::::::::::::::::::::::::::::::::::::::::::::::::
return logger, nil
}
/*
######################################################################################################## @(°_°)@ #######
*/