Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 18, 2025

Pull Request

Description

Frequent console.debug() calls impact performance. This PR adds a configurable logging class that respects the PostgreSQL debug_level configuration and can be disabled entirely in production (level 0).

  • New sysLogger class: Provides debug(), info(), warn(), error() methods with level-based filtering
  • Database integration: Reads debug_level from PostgreSQL, initialized in sysInitOnLoad.js
  • Global access: Available via sysFactory.Logger after initialization
  • Backward compatible: Existing console.debug() calls unchanged

Files Changed

Core Implementation:

  • www/sysLogger.js - Logger class with level constants (NONE=0, ERROR=1, WARN=5, INFO=8, DEBUG=10)
  • python/Index.py - Added script tag in HTML template
  • www/sysInitOnLoad.js - Initialize logger with database config

Documentation:

  • doc/appdev-logging.rst - Sphinx docs with usage, migration guide, best practices
  • doc/index.rst - Added to TOC
  • www/sysLogger.README.md - Quick reference

Testing:

  • test/integration/test_logger.py - Selenium tests for initialization, methods, levels, constants

Usage

// Replace console.debug() with level-aware logging
sysFactory.Logger.debug('TreeSimple JSONConfig:%o', Attributes);
sysFactory.Logger.info('User logged in:', userId);
sysFactory.Logger.warn('Deprecated function called');
sysFactory.Logger.error('Operation failed:', error);

// Configure via PostgreSQL
INSERT INTO system.config (config_group, "value") VALUES ('debug_level', '10');

Related Issue

Fixes #107

Type of Change

  • New feature
  • Documentation update

Checklist

  • I have read the contributing guidelines
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published

Additional Notes

CodeQL scan passed with no vulnerabilities. Logger is opt-in; migration from console.debug() can be gradual.

Original prompt

This section details on the original issue you should resolve

<issue_title>Add Proper Configurable Logger Class</issue_title>
<issue_description># Problem
Frequently occuring console.debug() messages impact performance.

Solution

Add a proper configurable (debug level) driven logging mechanism / class.

Priority

#105 reduced the performance impact, so implementation can wait until release 1.2.
</issue_description>

<agent_instructions>Propose a global JavaScript logging class (used in all .js files). The logging class should be configurable by multiple parameters / properties, e.g. LogLevel. LogLevel currently is configurable inside the PostgreSQL backend.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits November 18, 2025 08:50
Co-authored-by: clauspruefer <17313789+clauspruefer@users.noreply.github.com>
Co-authored-by: clauspruefer <17313789+clauspruefer@users.noreply.github.com>
Co-authored-by: clauspruefer <17313789+clauspruefer@users.noreply.github.com>
Copilot AI changed the title [WIP] Add proper configurable logger class for improved performance Add configurable sysLogger class for performance-optimized logging Nov 18, 2025
Copilot AI requested a review from clauspruefer November 18, 2025 08:56
Copilot finished work on behalf of clauspruefer November 18, 2025 08:56
@clauspruefer clauspruefer requested a review from Copilot November 18, 2025 09:05
Copilot finished reviewing on behalf of clauspruefer November 18, 2025 09:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a configurable logging system to improve performance by allowing log output to be controlled via database configuration instead of using always-on console.debug() calls.

Key changes:

  • New sysLogger class with level-based filtering (NONE, ERROR, WARN, INFO, DEBUG)
  • Integration with PostgreSQL debug_level configuration for centralized control
  • Comprehensive documentation including usage examples and migration guide

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 18 comments.

Show a summary per file
File Description
www/sysLogger.js New logger class implementation with configurable log levels
www/sysLogger.README.md Quick reference guide for logger usage
www/sysInitOnLoad.js Logger initialization with database-configured debug level
python/Index.py Added script tag to load logger before other modules
doc/appdev-logging.rst Complete Sphinx documentation with examples and best practices
doc/index.rst Added logging documentation to TOC
test/integration/test_logger.py Selenium-based integration tests for logger functionality

//------------------------------------------------------------------------------

sysLogger.prototype.setLogLevel = function(level) {
this.logLevel = parseInt(level) || 0;
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parseInt function without a radix can produce unexpected results. Always specify the radix (base 10) as the second parameter: parseInt(level, 10).

Suggested change
this.logLevel = parseInt(level) || 0;
this.logLevel = parseInt(level, 10) || 0;

Copilot uses AI. Check for mistakes.
sysLogger.prototype.setLogLevel = function(level) {
this.logLevel = parseInt(level) || 0;
this.enabled = this.logLevel > 0;
}
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon after function declaration closing brace. While not strictly required in JavaScript, the codebase style guide appears to use semicolons consistently (based on other lines in the file).

Suggested change
}
};

Copilot uses AI. Check for mistakes.

sysLogger.prototype.getLogLevel = function() {
return this.logLevel;
}
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon after function declaration closing brace for consistency with codebase style.

Suggested change
}
};

Copilot uses AI. Check for mistakes.
if (this.enabled && this.logLevel >= sysLogger.LOG_LEVEL_DEBUG) {
console.debug.apply(console, arguments);
}
}
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon after function declaration closing brace for consistency with codebase style.

Suggested change
}
};

Copilot uses AI. Check for mistakes.
if (this.enabled && this.logLevel >= sysLogger.LOG_LEVEL_INFO) {
console.info.apply(console, arguments);
}
}
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon after function declaration closing brace for consistency with codebase style.

Suggested change
}
};

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,187 @@
import os
import json
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'json' is not used.

Suggested change
import json

Copilot uses AI. Check for mistakes.
import globalconf

from selenium import webdriver
from selenium.webdriver.common.by import By
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'By' is not used.

Suggested change
from selenium.webdriver.common.by import By

Copilot uses AI. Check for mistakes.

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'Keys' is not used.

Suggested change
from selenium.webdriver.common.keys import Keys

Copilot uses AI. Check for mistakes.
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'WebDriverWait' is not used.

Suggested change
from selenium.webdriver.support.ui import WebDriverWait
# from selenium.webdriver.support.ui import WebDriverWait # Removed unused import

Copilot uses AI. Check for mistakes.
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'EC' is not used.

Suggested change
from selenium.webdriver.support import expected_conditions as EC

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Proper Configurable Logger Class

2 participants