mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-16 06:06:00 +00:00
use structed logging
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user