Skip to content

Commit 1378268

Browse files
committed
Improve log messages
1 parent a60155b commit 1378268

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

internal/file/file_manager_service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ func (fms *FileManagerService) downloadUpdatedFilesToTempLocation(ctx context.Co
633633
}
634634

635635
if len(downloadFiles) == 0 {
636-
slog.InfoContext(ctx, "No files are required to be downloaded")
636+
slog.InfoContext(ctx, "No files require downloading")
637637
return nil
638638
}
639639

internal/plugin/plugin_manager.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"log/slog"
1111
"sync"
1212

13+
"github.com/nginx/agent/v3/internal/logger"
1314
"github.com/nginx/agent/v3/internal/model"
1415

1516
pkg "github.com/nginx/agent/v3/pkg/config"
@@ -50,9 +51,14 @@ func addCommandAndFilePlugins(ctx context.Context, plugins []bus.Plugin, agentCo
5051
manifestLock *sync.RWMutex,
5152
) []bus.Plugin {
5253
if agentConfig.IsCommandGrpcClientConfigured() {
53-
grpcConnection, err := grpc.NewGrpcConnection(ctx, agentConfig, agentConfig.Command)
54+
newCtx := context.WithValue(
55+
ctx,
56+
logger.ServerTypeContextKey, slog.Any(logger.ServerTypeKey, model.Command),
57+
)
58+
59+
grpcConnection, err := grpc.NewGrpcConnection(newCtx, agentConfig, agentConfig.Command)
5460
if err != nil {
55-
slog.WarnContext(ctx, "Failed to create gRPC connection for command server", "error", err)
61+
slog.WarnContext(newCtx, "Failed to create gRPC connection for command server", "error", err)
5662
} else {
5763
commandPlugin := command.NewCommandPlugin(agentConfig, grpcConnection, model.Command)
5864
plugins = append(plugins, commandPlugin)
@@ -71,9 +77,14 @@ func addAuxiliaryCommandAndFilePlugins(ctx context.Context, plugins []bus.Plugin
7177
agentConfig *config.Config, manifestLock *sync.RWMutex,
7278
) []bus.Plugin {
7379
if agentConfig.IsAuxiliaryCommandGrpcClientConfigured() {
74-
auxGRPCConnection, err := grpc.NewGrpcConnection(ctx, agentConfig, agentConfig.AuxiliaryCommand)
80+
newCtx := context.WithValue(
81+
ctx,
82+
logger.ServerTypeContextKey, slog.Any(logger.ServerTypeKey, model.Auxiliary),
83+
)
84+
85+
auxGRPCConnection, err := grpc.NewGrpcConnection(newCtx, agentConfig, agentConfig.AuxiliaryCommand)
7586
if err != nil {
76-
slog.WarnContext(ctx, "Failed to create gRPC connection for auxiliary command server", "error", err)
87+
slog.WarnContext(newCtx, "Failed to create gRPC connection for auxiliary command server", "error", err)
7788
} else {
7889
auxCommandPlugin := command.NewCommandPlugin(agentConfig, auxGRPCConnection, model.Auxiliary)
7990
plugins = append(plugins, auxCommandPlugin)

0 commit comments

Comments
 (0)