Add mirrorFunc to handle mirrored messages

This commit is contained in:
Arthur Barr
2018-01-29 17:05:19 +00:00
parent 753612530f
commit 81bba0db32
3 changed files with 33 additions and 47 deletions

View File

@@ -19,6 +19,7 @@ package main
import (
"errors"
"fmt"
"io/ioutil"
"os"
"os/exec"
@@ -220,10 +221,17 @@ func doMain() error {
f := "/var/mqm/qmgrs/" + name + "/errors/AMQERR01"
if jsonLogs() {
f = f + ".json"
mirrorLifecycle, err = mirrorLog(f, func(msg string) {
// Print the message straight to stdout
fmt.Println(msg)
})
} else {
f = f + ".LOG"
mirrorLifecycle, err = mirrorLog(f, func(msg string) {
// Log the message, so we get a timestamp etc.
log.Println(msg)
})
}
mirrorLifecycle, err = mirrorLog(f, os.Stdout)
if err != nil {
return err
}