Skip to content

Commit fc95237

Browse files
committed
include crash detail in audit log transmission
closes #311
1 parent c3a1b52 commit fc95237

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/launcher.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,13 @@ class Launcher {
603603
await this.logAuditEvent('stopped')
604604
} else {
605605
this.state = States.CRASHED
606-
await this.logAuditEvent('crashed')
606+
// get last 20 lines of log
607+
// NOTE: the log is added to the body in a specific property that should not actually
608+
// be logged but rather extrated and examined to provide better reporting
609+
// NOTE: 20 is typically enough to see the likes of Out Of Memory errors entries
610+
const __launcherLog = this.getLog()?.toArray()?.slice(-20) || []
611+
const body = { __launcherLog, info: { code, signal, info: 'Node-RED exited with non zero exit code' } }
612+
await this.logAuditEvent('crashed', body)
607613

608614
// Only restart if our target state is not stopped
609615
if (this.targetState !== States.STOPPED) {

0 commit comments

Comments
 (0)