@@ -16,6 +16,7 @@ import (
1616 "github.com/deckhouse/deckhouse/pkg/log"
1717 "go.opentelemetry.io/otel"
1818
19+ pkg "github.com/flant/shell-operator/pkg"
1920 utils "github.com/flant/shell-operator/pkg/utils/labels"
2021)
2122
@@ -26,7 +27,7 @@ const (
2627func Run (cmd * exec.Cmd ) error {
2728 // TODO context: hook name, hook phase, hook binding
2829 // TODO observability
29- log .Debug ("Executing command" , slog .String ("command" , strings .Join (cmd .Args , " " )), slog .String ("dir" , cmd .Dir ))
30+ log .Debug ("Executing command" , slog .String (pkg . LogKeyCommand , strings .Join (cmd .Args , " " )), slog .String (pkg . LogKeyDir , cmd .Dir ))
3031
3132 return cmd .Run ()
3233}
@@ -100,8 +101,8 @@ func NewExecutor(dir string, entrypoint string, args []string, envs []string) *E
100101
101102func (e * Executor ) Output () ([]byte , error ) {
102103 e .logger .Debug ("Executing command" ,
103- slog .String ("command" , strings .Join (e .cmd .Args , " " )),
104- slog .String ("dir" , e .cmd .Dir ))
104+ slog .String (pkg . LogKeyCommand , strings .Join (e .cmd .Args , " " )),
105+ slog .String (pkg . LogKeyDir , e .cmd .Dir ))
105106 return e .cmd .Output ()
106107}
107108
@@ -117,12 +118,12 @@ func (e *Executor) RunAndLogLines(ctx context.Context, logLabels map[string]stri
117118
118119 stdErr := bytes .NewBuffer (nil )
119120 logEntry := utils .EnrichLoggerWithLabels (e .logger , logLabels )
120- stdoutLogEntry := logEntry .With ("output" , "stdout" )
121- stderrLogEntry := logEntry .With ("output" , "stderr" )
121+ stdoutLogEntry := logEntry .With (pkg . LogKeyOutput , "stdout" )
122+ stderrLogEntry := logEntry .With (pkg . LogKeyOutput , "stderr" )
122123
123124 log .Debug ("Executing command" ,
124- slog .String ("command" , strings .Join (e .cmd .Args , " " )),
125- slog .String ("dir" , e .cmd .Dir ))
125+ slog .String (pkg . LogKeyCommand , strings .Join (e .cmd .Args , " " )),
126+ slog .String (pkg . LogKeyDir , e .cmd .Dir ))
126127
127128 plo := & proxyLogger {
128129 ctx : ctx ,
@@ -208,7 +209,7 @@ func (pl *proxyLogger) Write(p []byte) (int, error) {
208209 }()
209210
210211 if ! ok {
211- pl .logger .Debug ("json log line not map[string]interface{}" , slog .Any ("line" , line ))
212+ pl .logger .Debug ("json log line not map[string]interface{}" , slog .Any (pkg . LogKeyLine , line ))
212213
213214 // fall back to using the logger
214215 pl .logger .Info (string (p ))
@@ -308,7 +309,7 @@ func (pl *proxyLogger) mergeAndLogInputLog(ctx context.Context, inputLog map[str
308309 if len (logLine ) > 10000 {
309310 logLine = fmt .Sprintf ("%s:truncated" , logLine [:10000 ])
310311
311- logger .Log (ctx , lvl .Level (), msg , slog .Any ("hook" , map [string ]any {
312+ logger .Log (ctx , lvl .Level (), msg , slog .Any (pkg . LogKeyHook , map [string ]any {
312313 "truncated" : logLine ,
313314 }))
314315
0 commit comments