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,17 +113,20 @@ export class Logger {
message: string, message: string,
eventObj?: LogEventObject, eventObj?: LogEventObject,
eventName?: string, eventName?: string,
track: boolean = true,
) { ) {
const msgObj: LogMessage = { message, isSystem: true }; const msgObj: LogMessage = { message, isSystem: true };
if (eventObj != null && eventObj.error != null) { if (eventObj != null && eventObj.error != null) {
msgObj.isStdErr = true; msgObj.isStdErr = true;
} }
this.log(msgObj); this.log(msgObj);
if (track) {
this.eventTracker.track( this.eventTracker.track(
eventName != null ? eventName : message, eventName != null ? eventName : message,
eventObj != null ? eventObj : {}, eventObj != null ? eventObj : {},
); );
} }
}
public lock(containerId: string): Bluebird.Disposer<() => void> { public lock(containerId: string): Bluebird.Disposer<() => void> {
return writeLock(containerId).disposer(release => { return writeLock(containerId).disposer(release => {
@ -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; let message = logType.humanName;
const objectName = this.objectNameForLogs(obj); const objectName = this.objectNameForLogs(obj);
if (objectName != null) { if (objectName != null) {
@ -168,7 +175,7 @@ export class Logger {
} }
message += ` due to '${errorMessage}'`; message += ` due to '${errorMessage}'`;
} }
this.logSystemMessage(message, obj, logType.eventName); this.logSystemMessage(message, obj, logType.eventName, track);
} }
public logConfigChange( public logConfigChange(