mirror of
https://github.com/fulpstation/fulpstation.git
synced 2025-12-10 18:11:47 +00:00
* Remove clockwork tgui theme * Perform early tgui initialization * Fix IE8 compatibility - No frills mode was not working on IE8 - Conditional comments do not work in embedded webview * Rethink console stubs, more proc inlining * some microoptimizations * Constraint window position * Rebuild tgui
45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
JavaScript
import { sendLogEntry } from 'tgui-dev-server/link/client';
|
|
import { act } from './byond';
|
|
|
|
const LEVEL_DEBUG = 0;
|
|
const LEVEL_LOG = 1;
|
|
const LEVEL_INFO = 2;
|
|
const LEVEL_WARN = 3;
|
|
const LEVEL_ERROR = 4;
|
|
|
|
const log = (level, ns, ...args) => {
|
|
// Send logs to a remote log collector
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
sendLogEntry(level, ns, ...args);
|
|
}
|
|
// Send important logs to the backend
|
|
if (level >= LEVEL_INFO) {
|
|
const logEntry = [ns, ...args]
|
|
.map(value => {
|
|
if (typeof value === 'string') {
|
|
return value;
|
|
}
|
|
if (value instanceof Error) {
|
|
return value.stack || String(value);
|
|
}
|
|
return JSON.stringify(value);
|
|
})
|
|
.filter(value => value)
|
|
.join(' ')
|
|
+ '\nUser Agent: ' + navigator.userAgent;
|
|
act(window.__ref__, 'tgui:log', {
|
|
log: logEntry,
|
|
});
|
|
}
|
|
};
|
|
|
|
export const createLogger = ns => {
|
|
return {
|
|
debug: (...args) => log(LEVEL_DEBUG, ns, ...args),
|
|
log: (...args) => log(LEVEL_LOG, ns, ...args),
|
|
info: (...args) => log(LEVEL_INFO, ns, ...args),
|
|
warn: (...args) => log(LEVEL_WARN, ns, ...args),
|
|
error: (...args) => log(LEVEL_ERROR, ns, ...args),
|
|
};
|
|
};
|