openreplay/frontend/app/logger/index.js
Andrey Babushkin fd5c0c9747
Add lokalisation (#3092)
* applied eslint

* add locales and lint the project

* removed error boundary

* updated locales

* fix min files

* fix locales
2025-03-06 17:43:15 +01:00

58 lines
1.2 KiB
JavaScript

import { options } from 'App/dev/console';
function log(...args) {
if (!window.env.PRODUCTION || options.verbose) {
if (Object.keys(groupTm).length > 0) {
console.groupEnd();
}
console.log(...args);
}
}
function warn(...args) {
if (!window.env.PRODUCTION || options.verbose) {
console.warn(...args);
}
options.exceptionsLogs.push(args);
}
function error(...args) {
if (!window.env.PRODUCTION || options.verbose) {
console.error(...args);
options.exceptionsLogs.push(args);
}
}
let groupTm = {};
const groupedLogs = {};
function group(groupName, ...args) {
if (!window.env.PRODUCTION || options.verbose) {
if (groupTm[groupName]) {
clearTimeout(groupTm[groupName]);
groupTm[groupName] = null;
} else {
groupedLogs[groupName] = [];
}
groupedLogs[groupName].push(args);
groupTm[groupName] = setTimeout(() => {
console.groupCollapsed(groupName);
groupedLogs[groupName].forEach((log) => {
console.log(...log);
});
console.groupEnd();
delete groupTm[groupName];
delete groupedLogs[groupName];
}, 500);
options.exceptionsLogs.push(args);
}
}
export default {
info: log,
log,
warn,
error,
group,
};