use structed logging

This commit is contained in:
evanpelle
2024-09-01 12:51:20 -07:00
parent 735a2ae57b
commit 026a0cddbe
10 changed files with 292 additions and 31 deletions
+21
View File
@@ -0,0 +1,21 @@
export enum LogSeverity {
DEBUG = 'DEBUG',
INFO = 'INFO',
WARN = 'WARN',
ERROR = 'ERROR',
FATAL = 'FATAL'
}
export function slog(eventType: string, description, data: any, severity = LogSeverity.INFO): void {
const logEntry = {
eventType: eventType,
description: description,
severity: severity,
data: data
};
if (process.env.GAME_ENV == 'dev') {
console.log(description)
} else {
console.log(JSON.stringify(logEntry));
}
}