From e07110108fcc11c630ef2526874fdf5f9a0a5a7b Mon Sep 17 00:00:00 2001 From: Arthur Barr Date: Mon, 5 Mar 2018 10:57:05 +0000 Subject: [PATCH] Mirror MQ system logs --- cmd/runmqserver/logging.go | 10 ++++++++-- cmd/runmqserver/main.go | 7 ++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/cmd/runmqserver/logging.go b/cmd/runmqserver/logging.go index 54fb2f9..6814124 100644 --- a/cmd/runmqserver/logging.go +++ b/cmd/runmqserver/logging.go @@ -63,9 +63,15 @@ func formatSimple(datetime string, message string) string { return fmt.Sprintf("%v %v\n", datetime, message) } -func mirrorLogs(ctx context.Context, wg *sync.WaitGroup, name string, fromStart bool, mf mirrorFunc) (chan error, error) { +// mirrorSystemErrorLogs starts a goroutine to mirror the contents of the MQ system error logs +func mirrorSystemErrorLogs(ctx context.Context, wg *sync.WaitGroup, mf mirrorFunc) (chan error, error) { + // Always use the JSON log as the source + return mirrorLog(ctx, wg, "/var/mqm/errors/AMQERR01.json", false, mf) +} + +// mirrorQueueManagerErrorLogs starts a goroutine to mirror the contents of the MQ queue manager error logs +func mirrorQueueManagerErrorLogs(ctx context.Context, wg *sync.WaitGroup, name string, fromStart bool, mf mirrorFunc) (chan error, error) { // Always use the JSON log as the source - // Put the queue manager name in quotes to handle cases like name=.. qm, err := mqini.GetQueueManager(name) if err != nil { logDebug(err) diff --git a/cmd/runmqserver/main.go b/cmd/runmqserver/main.go index 57a33d1..c24c467 100644 --- a/cmd/runmqserver/main.go +++ b/cmd/runmqserver/main.go @@ -84,7 +84,12 @@ func doMain() error { cancelMirror() }() // TODO: Use the error channel - _, err = mirrorLogs(ctx, &wg, name, newQM, mf) + _, err = mirrorSystemErrorLogs(ctx, &wg, mf) + if err != nil { + logTermination(err) + return err + } + _, err = mirrorQueueManagerErrorLogs(ctx, &wg, name, newQM, mf) if err != nil { logTermination(err) return err