@@ -13,7 +13,6 @@ import (
1313 "github.com/tecnickcom/gogen/pkg/bootstrap"
1414 "github.com/tecnickcom/gogen/pkg/config"
1515 "github.com/tecnickcom/gogen/pkg/httputil/jsendx"
16- "github.com/tecnickcom/gogen/pkg/logsrv"
1716 "github.com/tecnickcom/gogen/pkg/logutil"
1817)
1918
@@ -34,6 +33,7 @@ func New(version, release string, bootstrapFn bootstrapFunc) (*cobra.Command, er
3433 }
3534 )
3635
36+ // command-line arguments
3737 rootCmd .Flags ().StringVarP (& argConfigDir , "configDir" , "c" , "" , "Configuration directory to be added on top of the search list" )
3838 rootCmd .Flags ().StringVarP (& argLogFormat , "logFormat" , "f" , "" , "Logging format: CONSOLE, JSON" )
3939 rootCmd .Flags ().StringVarP (& argLogLevel , "logLevel" , "o" , "" , "Log level: EMERGENCY, ALERT, CRITICAL, ERROR, WARNING, NOTICE, INFO, DEBUG" )
@@ -47,6 +47,8 @@ func New(version, release string, bootstrapFn bootstrapFunc) (*cobra.Command, er
4747 return fmt .Errorf ("failed loading config: %w" , err )
4848 }
4949
50+ // Configure logger
51+
5052 if argLogFormat != "" {
5153 cfg .Log .Format = argLogFormat
5254 }
@@ -65,7 +67,6 @@ func New(version, release string, bootstrapFn bootstrapFunc) (*cobra.Command, er
6567 return fmt .Errorf ("log config error: %w" , err )
6668 }
6769
68- // Configure logger
6970 logattr := []logutil.Attr {
7071 slog .String ("program" , AppName ),
7172 slog .String ("version" , version ),
@@ -78,19 +79,15 @@ func New(version, release string, bootstrapFn bootstrapFunc) (*cobra.Command, er
7879 logutil .WithLevel (logLevel ),
7980 logutil .WithCommonAttr (logattr ... ),
8081 )
81- // if err != nil {
82- // return fmt.Errorf("failed configuring logger: %w", err)
83- // }
84-
85- l := logsrv .NewLogger (logcfg )
8682
8783 appInfo := & jsendx.AppInfo {
8884 ProgramName : AppName ,
8985 ProgramVersion : version ,
9086 ProgramRelease : release ,
9187 }
9288
93- // Confifure metrics
89+ // Initialize metrics
90+
9491 mtr := metrics .New ()
9592
9693 // Wait group used for graceful shutdown of all dependants (e.g.: servers).
@@ -102,7 +99,7 @@ func New(version, release string, bootstrapFn bootstrapFunc) (*cobra.Command, er
10299 // Boostrap application
103100 return bootstrapFn (
104101 bind (cfg , appInfo , mtr , wg , sc ),
105- bootstrap .WithLogger ( l ),
102+ bootstrap .WithLogConfig ( logcfg ),
106103 bootstrap .WithCreateMetricsClientFunc (mtr .CreateMetricsClientFunc ),
107104 bootstrap .WithShutdownTimeout (time .Duration (cfg .ShutdownTimeout )* time .Second ),
108105 bootstrap .WithShutdownWaitGroup (wg ),
0 commit comments