Skip to content

Commit

Permalink
system-logs: Do not log to console when system-logging is enabled
Browse files Browse the repository at this point in the history
Console logs can have a huge impact on performance, especially on low-end devices.
  • Loading branch information
rafaellehmkuhl authored and ArturoManzoli committed Oct 7, 2024
1 parent 989a0f4 commit b61dc53
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/libs/system-logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ const saveLogEventInDB = (event: LogEvent): void => {

const enableSystemLogging = localStorage.getItem(systemLoggingEnablingKey)
if (enableSystemLogging === 'true') {
console.log(`
System logging is enabled.
This means that all console logs will be saved to the database, and won't be displayed in the console.
To disable system logging go to "Configuration" -> "Development".
`)
const oldConsoleFunction = {
error: console.error,
warn: console.warn,
Expand All @@ -55,10 +60,9 @@ if (enableSystemLogging === 'true') {
trace: console.trace,
log: console.log,
}
Object.entries(oldConsoleFunction).forEach(([level, fn]) => {
Object.entries(oldConsoleFunction).forEach(([level]) => {
// @ts-ignore
window.console[level] = (...o: any[]) => {
fn(...o)
let wholeMessage = ''
o.forEach((m) => {
let msg = m
Expand Down

0 comments on commit b61dc53

Please sign in to comment.