@@ -137,20 +137,20 @@ func loadConfig() {
137137
138138 // read the config file
139139 if err := viper .ReadInConfig (); err != nil {
140- logger .Error ( "unable to read config file" , slog .String ("error" , err .Error ()))
140+ logger .ErrorContext ( context . Background (), "unable to read config file" , slog .String ("error" , err .Error ()))
141141 os .Exit (1 )
142142 }
143143
144144 // unmarshal the config
145145 cfg = & config.Config {}
146146 if err := viper .Unmarshal (cfg ); err != nil {
147- logger .Error ( "unable to unmarshal config" , slog .String ("error" , err .Error ()))
147+ logger .ErrorContext ( context . Background (), "unable to unmarshal config" , slog .String ("error" , err .Error ()))
148148 os .Exit (1 )
149149 }
150150
151151 // validate the config
152152 if err := cfg .Validate (); err != nil {
153- logger .Error ( "invalid configuration" , slog .String ("error" , err .Error ()))
153+ logger .ErrorContext ( context . Background (), "invalid configuration" , slog .String ("error" , err .Error ()))
154154 os .Exit (1 )
155155 }
156156}
@@ -226,19 +226,19 @@ func run(_ *cobra.Command, _ []string) error {
226226 }
227227
228228 <- ctx .Done ()
229- logger .Info ( "shutting down" )
229+ logger .InfoContext ( ctx , "shutting down" )
230230
231231 // shutting down HTTP server
232232 ctx , cancel = context .WithTimeout (context .Background (), 30 * time .Second )
233233 defer cancel ()
234- logger .Info ( "stopping http server" )
234+ logger .InfoContext ( ctx , "stopping http server" )
235235 if err := server .Stop (ctx ); err != nil {
236- logger .Error ( "unable to stop http service" , slog .String ("error" , err .Error ()))
236+ logger .ErrorContext ( ctx , "unable to stop http service" , slog .String ("error" , err .Error ()))
237237 }
238238
239239 if err := eg .Wait (); err != nil {
240240 if errors .Is (err , context .Canceled ) {
241- logger .Info ( "Program interrupted by user" )
241+ logger .InfoContext ( ctx , "Program interrupted by user" )
242242 return nil
243243 }
244244 return fmt .Errorf ("error during execution: %w" , err )
@@ -281,7 +281,7 @@ func startHTTPServer(eg *errgroup.Group, registry *prometheus.Registry, healthSt
281281 }
282282
283283 eg .Go (func () error {
284- logger .Info (
284+ logger .InfoContext ( context . Background (),
285285 "starting http server" ,
286286 slog .String ("component" , "http-server" ),
287287 slog .String ("addr" , fmt .Sprintf ("%s:%d" , cfg .HTTP .Host , cfg .HTTP .Port )),
@@ -306,7 +306,7 @@ func startStatusWatcher(
306306) {
307307 eg .Go (func () error {
308308 statusWatcher := watcher .NewStatusWatcher (blockfrost , cardano , metrics , healthStore )
309- logger .Info (
309+ logger .InfoContext ( ctx ,
310310 "starting watcher" ,
311311 slog .String ("component" , "status-watcher" ),
312312 )
@@ -331,7 +331,7 @@ func startPoolWatcher(
331331 RefreshInterval : time .Second * time .Duration (cfg .PoolWatcherConfig .RefreshInterval ),
332332 Network : cfg .Network ,
333333 }
334- logger .Info (
334+ logger .InfoContext ( ctx ,
335335 "starting watcher" ,
336336 slog .String ("component" , "pool-watcher" ),
337337 )
@@ -359,7 +359,7 @@ func startNetworkWatcher(
359359 RefreshInterval : time .Second * time .Duration (cfg .PoolWatcherConfig .RefreshInterval ),
360360 Network : cfg .Network ,
361361 }
362- logger .Info (
362+ logger .InfoContext ( ctx ,
363363 "starting watcher" ,
364364 slog .String ("component" , "network-watcher" ),
365365 )
@@ -388,7 +388,7 @@ func startBlockWatcher(
388388 RefreshInterval : time .Second * time .Duration (cfg .BlockWatcherConfig .RefreshInterval ),
389389 }
390390 blockWatcher := watcher .NewBlockWatcher (cardano , blockfrost , sl , pools , metrics , db , healthStore , options )
391- logger .Info (
391+ logger .InfoContext ( ctx ,
392392 "starting watcher" ,
393393 slog .String ("component" , "block-watcher" ),
394394 )
@@ -403,7 +403,7 @@ func startBlockWatcher(
403403// used for the flag parsing
404404func checkError (err error , msg string ) {
405405 if err != nil {
406- logger .Error ( msg , slog .String ("error" , err .Error ()))
406+ logger .ErrorContext ( context . Background (), msg , slog .String ("error" , err .Error ()))
407407 os .Exit (1 )
408408 }
409409}
0 commit comments