forked from TrueCloudLab/frostfs-node
[#1437] node: Use ctx for logging
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
c16dae8b4d
commit
6db46257c0
157 changed files with 764 additions and 713 deletions
|
@ -73,9 +73,9 @@ func main() {
|
|||
}
|
||||
|
||||
func initAndLog(c *cfg, name string, initializer func(*cfg)) {
|
||||
c.log.Info(fmt.Sprintf("initializing %s service...", name))
|
||||
c.log.Info(context.Background(), fmt.Sprintf("initializing %s service...", name))
|
||||
initializer(c)
|
||||
c.log.Info(name + " service has been successfully initialized")
|
||||
c.log.Info(context.Background(), name+" service has been successfully initialized")
|
||||
}
|
||||
|
||||
func initApp(ctx context.Context, c *cfg) {
|
||||
|
@ -120,25 +120,25 @@ func initApp(ctx context.Context, c *cfg) {
|
|||
}
|
||||
|
||||
func runAndLog(ctx context.Context, c *cfg, name string, logSuccess bool, starter func(context.Context, *cfg)) {
|
||||
c.log.Info(fmt.Sprintf("starting %s service...", name))
|
||||
c.log.Info(ctx, fmt.Sprintf("starting %s service...", name))
|
||||
starter(ctx, c)
|
||||
|
||||
if logSuccess {
|
||||
c.log.Info(name + " service started successfully")
|
||||
c.log.Info(ctx, name+" service started successfully")
|
||||
}
|
||||
}
|
||||
|
||||
func stopAndLog(c *cfg, name string, stopper func() error) {
|
||||
c.log.Debug(fmt.Sprintf("shutting down %s service", name))
|
||||
c.log.Debug(context.Background(), fmt.Sprintf("shutting down %s service", name))
|
||||
|
||||
err := stopper()
|
||||
if err != nil {
|
||||
c.log.Debug(fmt.Sprintf("could not shutdown %s server", name),
|
||||
c.log.Debug(context.Background(), fmt.Sprintf("could not shutdown %s server", name),
|
||||
zap.String("error", err.Error()),
|
||||
)
|
||||
}
|
||||
|
||||
c.log.Debug(name + " service has been stopped")
|
||||
c.log.Debug(context.Background(), name+" service has been stopped")
|
||||
}
|
||||
|
||||
func bootUp(ctx context.Context, c *cfg) {
|
||||
|
@ -150,7 +150,7 @@ func bootUp(ctx context.Context, c *cfg) {
|
|||
}
|
||||
|
||||
func wait(c *cfg) {
|
||||
c.log.Info(logs.CommonApplicationStarted,
|
||||
c.log.Info(context.Background(), logs.CommonApplicationStarted,
|
||||
zap.String("version", misc.Version))
|
||||
|
||||
<-c.done // graceful shutdown
|
||||
|
@ -160,12 +160,12 @@ func wait(c *cfg) {
|
|||
go func() {
|
||||
defer drain.Done()
|
||||
for err := range c.internalErr {
|
||||
c.log.Warn(logs.FrostFSNodeInternalApplicationError,
|
||||
c.log.Warn(context.Background(), logs.FrostFSNodeInternalApplicationError,
|
||||
zap.String("message", err.Error()))
|
||||
}
|
||||
}()
|
||||
|
||||
c.log.Debug(logs.FrostFSNodeWaitingForAllProcessesToStop)
|
||||
c.log.Debug(context.Background(), logs.FrostFSNodeWaitingForAllProcessesToStop)
|
||||
|
||||
c.wg.Wait()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue