Skip to content

Commit

Permalink
more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
jcollins-axway committed Nov 17, 2023
1 parent 375395c commit bfb1c4c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions pkg/beater/custom_beater.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,22 @@ func (b *httpLogBeater) Run(beater *beat.Beat) error {
defer r.Body.Close()

if err != nil {
b.logger.Error(fmt.Errorf("error while reading request body: %s", err))
b.logger.WithError(err).Error("reading request body")
}

w.WriteHeader(200)
go b.processAndDispatchEvent(ctx, logData)
})
},
)

/* Start a new HTTP server in a separate Go routine that will be the target
for the HTTP Log plugin. It should write events it gets to eventChannel */
go func() {
if err := http.ListenAndServe(fmt.Sprintf(":%d", config.GetAgentConfig().HttpLogPluginConfig.Port),
nil); err != nil {
b.logger.Fatalf("Unable to start the HTTP Server: %s", err)
err := http.ListenAndServe(fmt.Sprintf(":%d", config.GetAgentConfig().HttpLogPluginConfig.Port), nil)
if err != nil {
b.logger.WithError(err).Fatalf("unable to start the HTTP Server")
}
b.logger.Infof("Started HTTP server on port %d to receive request logs", config.GetAgentConfig().HttpLogPluginConfig.Port)
b.logger.WithField("port", config.GetAgentConfig().HttpLogPluginConfig.Port).WithField("path", config.GetAgentConfig().HttpLogPluginConfig.Path).Info("started HTTP server")
}()

<-b.done
Expand Down

0 comments on commit bfb1c4c

Please sign in to comment.