events: Allow system messages to not be tracked

Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
Cameron Diver 2019-02-14 13:24:50 +00:00
parent c211efe399
commit 83d53cfb56
No known key found for this signature in database
GPG Key ID: 49690ED87032539F

View File

@ -113,16 +113,19 @@ export class Logger {
message: string,
eventObj?: LogEventObject,
eventName?: string,
track: boolean = true,
) {
const msgObj: LogMessage = { message, isSystem: true };
if (eventObj != null && eventObj.error != null) {
msgObj.isStdErr = true;
}
this.log(msgObj);
this.eventTracker.track(
eventName != null ? eventName : message,
eventObj != null ? eventObj : {},
);
if (track) {
this.eventTracker.track(
eventName != null ? eventName : message,
eventObj != null ? eventObj : {},
);
}
}
public lock(containerId: string): Bluebird.Disposer<() => void> {
@ -153,7 +156,11 @@ export class Logger {
});
}
public logSystemEvent(logType: LogType, obj: LogEventObject): void {
public logSystemEvent(
logType: LogType,
obj: LogEventObject,
track: boolean = true,
): void {
let message = logType.humanName;
const objectName = this.objectNameForLogs(obj);
if (objectName != null) {
@ -168,7 +175,7 @@ export class Logger {
}
message += ` due to '${errorMessage}'`;
}
this.logSystemMessage(message, obj, logType.eventName);
this.logSystemMessage(message, obj, logType.eventName, track);
}
public logConfigChange(