Add configurable sysLogger class for performance-optimized logging#180
Add configurable sysLogger class for performance-optimized logging#180
Conversation
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>
There was a problem hiding this comment.
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
sysLoggerclass with level-based filtering (NONE, ERROR, WARN, INFO, DEBUG) - Integration with PostgreSQL
debug_levelconfiguration 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; |
There was a problem hiding this comment.
The parseInt function without a radix can produce unexpected results. Always specify the radix (base 10) as the second parameter: parseInt(level, 10).
| this.logLevel = parseInt(level) || 0; | |
| this.logLevel = parseInt(level, 10) || 0; |
| sysLogger.prototype.setLogLevel = function(level) { | ||
| this.logLevel = parseInt(level) || 0; | ||
| this.enabled = this.logLevel > 0; | ||
| } |
There was a problem hiding this comment.
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).
| } | |
| }; |
|
|
||
| sysLogger.prototype.getLogLevel = function() { | ||
| return this.logLevel; | ||
| } |
There was a problem hiding this comment.
Missing semicolon after function declaration closing brace for consistency with codebase style.
| } | |
| }; |
| if (this.enabled && this.logLevel >= sysLogger.LOG_LEVEL_DEBUG) { | ||
| console.debug.apply(console, arguments); | ||
| } | ||
| } |
There was a problem hiding this comment.
Missing semicolon after function declaration closing brace for consistency with codebase style.
| } | |
| }; |
| if (this.enabled && this.logLevel >= sysLogger.LOG_LEVEL_INFO) { | ||
| console.info.apply(console, arguments); | ||
| } | ||
| } |
There was a problem hiding this comment.
Missing semicolon after function declaration closing brace for consistency with codebase style.
| } | |
| }; |
| @@ -0,0 +1,187 @@ | |||
| import os | |||
| import json | |||
There was a problem hiding this comment.
Import of 'json' is not used.
| import json |
| import globalconf | ||
|
|
||
| from selenium import webdriver | ||
| from selenium.webdriver.common.by import By |
There was a problem hiding this comment.
Import of 'By' is not used.
| from selenium.webdriver.common.by import By |
|
|
||
| from selenium import webdriver | ||
| from selenium.webdriver.common.by import By | ||
| from selenium.webdriver.common.keys import Keys |
There was a problem hiding this comment.
Import of 'Keys' is not used.
| from selenium.webdriver.common.keys import Keys |
| 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 |
There was a problem hiding this comment.
Import of 'WebDriverWait' is not used.
| from selenium.webdriver.support.ui import WebDriverWait | |
| # from selenium.webdriver.support.ui import WebDriverWait # Removed unused import |
| 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 |
There was a problem hiding this comment.
Import of 'EC' is not used.
| from selenium.webdriver.support import expected_conditions as EC |
Pull Request
Description
Frequent
console.debug()calls impact performance. This PR adds a configurable logging class that respects the PostgreSQLdebug_levelconfiguration and can be disabled entirely in production (level 0).sysLoggerclass: Providesdebug(),info(),warn(),error()methods with level-based filteringdebug_levelfrom PostgreSQL, initialized insysInitOnLoad.jssysFactory.Loggerafter initializationconsole.debug()calls unchangedFiles 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 templatewww/sysInitOnLoad.js- Initialize logger with database configDocumentation:
doc/appdev-logging.rst- Sphinx docs with usage, migration guide, best practicesdoc/index.rst- Added to TOCwww/sysLogger.README.md- Quick referenceTesting:
test/integration/test_logger.py- Selenium tests for initialization, methods, levels, constantsUsage
Related Issue
Fixes #107
Type of Change
Checklist
Additional Notes
CodeQL scan passed with no vulnerabilities. Logger is opt-in; migration from
console.debug()can be gradual.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.