Mirror error logs by default
This commit is contained in:
@@ -159,12 +159,22 @@ func jsonLogs() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func mirrorLogs() bool {
|
func mirrorLogs(name string) (chan bool, error) {
|
||||||
e := os.Getenv("MQ_ALPHA_MIRROR_ERROR_LOGS")
|
f := "/var/mqm/qmgrs/" + name + "/errors/AMQERR01"
|
||||||
if e == "true" || e == "1" {
|
if jsonLogs() {
|
||||||
return true
|
f = f + ".json"
|
||||||
|
return mirrorLog(f, func(msg string) {
|
||||||
|
// Print the message straight to stdout
|
||||||
|
fmt.Println(msg)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
return false
|
f = f + ".LOG"
|
||||||
|
return mirrorLog(f, func(msg string) {
|
||||||
|
if strings.HasPrefix(msg, "AMQ") {
|
||||||
|
// Log the message, so we get a timestamp etc.
|
||||||
|
log.Println(msg)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
type simpleTextFormatter struct {
|
type simpleTextFormatter struct {
|
||||||
@@ -176,7 +186,7 @@ func (f *simpleTextFormatter) Format(entry *logrus.Entry) ([]byte, error) {
|
|||||||
entry.Message = "DEBUG: " + entry.Message
|
entry.Message = "DEBUG: " + entry.Message
|
||||||
}
|
}
|
||||||
// Use a simple, human-readable format, with a timestamp
|
// Use a simple, human-readable format, with a timestamp
|
||||||
return []byte(fmt.Sprintf("%s %s\n", entry.Time.Format("2006-01-02 15:04:05"), entry.Message)), nil
|
return []byte(fmt.Sprintf("%s %s\n", entry.Time.Format("2006/01/02 15:04:05"), entry.Message)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func configureLogger() {
|
func configureLogger() {
|
||||||
@@ -240,27 +250,9 @@ func doMain() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
var mirrorLifecycle chan bool
|
mirrorLifecycle, err := mirrorLogs(name)
|
||||||
if mirrorLogs() {
|
if err != nil {
|
||||||
f := "/var/mqm/qmgrs/" + name + "/errors/AMQERR01"
|
return err
|
||||||
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) {
|
|
||||||
if strings.HasPrefix(msg, "AMQ") {
|
|
||||||
// Log the message, so we get a timestamp etc.
|
|
||||||
log.Println(msg)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
err = createQueueManager(name)
|
err = createQueueManager(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -281,18 +273,14 @@ func doMain() error {
|
|||||||
signalControl <- startReaping
|
signalControl <- startReaping
|
||||||
// Reap zombies now, just in case we've already got some
|
// Reap zombies now, just in case we've already got some
|
||||||
signalControl <- reapNow
|
signalControl <- reapNow
|
||||||
|
|
||||||
// Write a file to indicate that chkmqready should now work as normal
|
// Write a file to indicate that chkmqready should now work as normal
|
||||||
ready.Set()
|
ready.Set()
|
||||||
|
|
||||||
// Wait for terminate signal
|
// Wait for terminate signal
|
||||||
<-signalControl
|
<-signalControl
|
||||||
if mirrorLogs() {
|
// Tell the mirroring goroutine to shutdown
|
||||||
// Tell the mirroring goroutine to shutdown
|
mirrorLifecycle <- true
|
||||||
mirrorLifecycle <- true
|
// Wait for the mirroring goroutine to finish cleanly
|
||||||
// Wait for the mirroring goroutine to finish cleanly
|
<-mirrorLifecycle
|
||||||
<-mirrorLifecycle
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -468,8 +468,6 @@ func TestErrorLogRotation(t *testing.T) {
|
|||||||
"MQ_QMGR_NAME=" + qmName,
|
"MQ_QMGR_NAME=" + qmName,
|
||||||
"MQMAXERRORLOGSIZE=65536",
|
"MQMAXERRORLOGSIZE=65536",
|
||||||
"MQ_ALPHA_JSON_LOGS=true",
|
"MQ_ALPHA_JSON_LOGS=true",
|
||||||
"MQ_ALPHA_MIRROR_ERROR_LOGS=true",
|
|
||||||
//"DEBUG=true",
|
|
||||||
},
|
},
|
||||||
ExposedPorts: nat.PortSet{
|
ExposedPorts: nat.PortSet{
|
||||||
"1414/tcp": struct{}{},
|
"1414/tcp": struct{}{},
|
||||||
|
|||||||
Reference in New Issue
Block a user