mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
* init map view * switching off 3d buildings when sattelite view is on * rename menu items * upgrading dependencies, adding provider to popups * adding screenshot for map view * fixing readme * next release version
65 lines
1.6 KiB
JavaScript
65 lines
1.6 KiB
JavaScript
/*
|
|
* Copyright (c) 2026 by Christian Kellner.
|
|
* Licensed under Apache-2.0 with Commons Clause and Attribution/Naming Clause
|
|
*/
|
|
|
|
const COLORS = {
|
|
debug: '\x1b[36m',
|
|
info: '\x1b[32m',
|
|
warn: '\x1b[33m',
|
|
error: '\x1b[31m',
|
|
reset: '\x1b[0m',
|
|
};
|
|
|
|
const env = process.env.NODE_ENV || 'development';
|
|
const useColor = process.stdout.isTTY || process.stderr.isTTY;
|
|
|
|
function ts() {
|
|
const d = new Date();
|
|
const yyyy = d.getFullYear();
|
|
const mm = String(d.getMonth() + 1).padStart(2, '0');
|
|
const dd = String(d.getDate()).padStart(2, '0');
|
|
const hh = String(d.getHours()).padStart(2, '0');
|
|
const mi = String(d.getMinutes()).padStart(2, '0');
|
|
const ss = String(d.getSeconds()).padStart(2, '0');
|
|
return `${yyyy}-${mm}-${dd} ${hh}:${mi}:${ss}`;
|
|
}
|
|
|
|
function lvl(level) {
|
|
const upper = level.toUpperCase();
|
|
if (!useColor) return upper;
|
|
return `${COLORS[level] || ''}${upper}${COLORS.reset}`;
|
|
}
|
|
|
|
/* eslint-disable no-console */
|
|
function log(level, ...args) {
|
|
if (level === 'debug' && env !== 'development') {
|
|
return; // Skip debug logs in non-development environments
|
|
}
|
|
|
|
const prefix = `[${ts()}] ${lvl(level)}:`;
|
|
switch (level) {
|
|
case 'debug':
|
|
console.debug(prefix, ...args);
|
|
break;
|
|
case 'info':
|
|
console.info(prefix, ...args);
|
|
break;
|
|
case 'warn':
|
|
console.warn(prefix, ...args);
|
|
break;
|
|
case 'error':
|
|
console.error(prefix, ...args);
|
|
break;
|
|
default:
|
|
console.log(prefix, ...args);
|
|
}
|
|
}
|
|
|
|
export default {
|
|
debug: (...a) => log('debug', ...a),
|
|
info: (...a) => log('info', ...a),
|
|
warn: (...a) => log('warn', ...a),
|
|
error: (...a) => log('error', ...a),
|
|
};
|