@@ -222,18 +222,63 @@ func handleAdd(ctx context.Context, path string, cfg config.Config, addCmd *flag
222222 }
223223 name , spec := inferSourceSpec (remaining [0 ])
224224
225+ fmt .Printf ("Adding log source: %s\n " , remaining [0 ])
226+ if spec .Type == "file" {
227+ fmt .Printf (" Type: file path\n " )
228+ fmt .Printf (" Path: %s\n " , spec .Params ["path" ])
229+ } else {
230+ fmt .Printf (" Type: systemd unit\n " )
231+ fmt .Printf (" Unit: %s\n " , spec .Params ["unit" ])
232+ }
233+
225234 if err := formatguesser .Add (ctx , & cfg , name , spec , formatguesser.AddRequest {
226235 Override : * override ,
227236 AllowMixed : * ignoreFormatChange ,
228237 }); err != nil {
229238 log .Fatalf ("Failed to guess the source format, error: %v" , err )
230239 }
240+
241+ // Find the app we just added/updated
242+ var addedApp * config.AppSpec
243+ for i := range cfg .Apps {
244+ if cfg .Apps [i ].Name == name || (cfg .Apps [i ].Source .Type == spec .Type &&
245+ cfg .Apps [i ].Source .Params ["unit" ] == spec .Params ["unit" ] &&
246+ cfg .Apps [i ].Source .Params ["path" ] == spec .Params ["path" ]) {
247+ addedApp = & cfg .Apps [i ]
248+ break
249+ }
250+ }
251+
252+ if addedApp == nil {
253+ log .Fatalf ("Failed to find the added app in config" )
254+ }
255+
256+ parserSpec := cfg .Parsers [addedApp .ParserID ]
257+
258+ fmt .Printf ("\n Detected log format:\n " )
259+ fmt .Printf (" Parser: %s\n " , parserSpec .Type )
260+ fmt .Printf (" Timestamp field: %s\n " , parserSpec .Params ["timestamp_field" ])
261+ fmt .Printf (" Timestamp format: %s\n " , parserSpec .Params ["timestamp_format" ])
262+ fmt .Printf (" Level field: %s\n " , parserSpec .Params ["level_field" ])
263+ fmt .Printf (" Message field: %s\n " , parserSpec .Params ["message_field" ])
264+ if traceField := parserSpec .Params ["trace_id_field" ]; traceField != "" {
265+ fmt .Printf (" Trace ID field: %s\n " , traceField )
266+ }
267+
231268 if strings .TrimSpace (* healthURL ) != "" {
269+ fmt .Printf ("\n Attaching health check: %s\n " , strings .TrimSpace (* healthURL ))
232270 attachHTTPHealth (& cfg , name , spec , strings .TrimSpace (* healthURL ))
233271 }
272+
234273 if err := cfg .Persist (path ); err != nil {
235274 log .Fatalf ("Failed to write the file config, error: %v" , err )
236275 }
276+
277+ fmt .Printf ("\n Configuration saved to: %s\n " , path )
278+ fmt .Printf ("\n Added app configuration:\n " )
279+ fmt .Printf (" Name: %s\n " , addedApp .Name )
280+ fmt .Printf (" Parser ID: %s\n " , addedApp .ParserID )
281+ fmt .Printf (" Source Type: %s\n " , addedApp .Source .Type )
237282}
238283
239284func handleSet (path string , cfg config.Config , setCmd * flag.FlagSet ) {
0 commit comments