Add configurable log level for Python and JS modules

Introduced LOG_LEVEL configuration in both Python and JavaScript to control logging verbosity. Updated logger initialization in canvas_node.py and LoggerUtils.js to use the new LOG_LEVEL from config files.
This commit is contained in:
Dariusz L
2025-07-03 13:15:33 +02:00
parent dfa7309132
commit aa31a347d1
4 changed files with 11 additions and 3 deletions

View File

@@ -28,8 +28,9 @@ import os
try:
from python.logger import logger, LogLevel, debug, info, warn, error, exception
from python.config import LOG_LEVEL
logger.set_module_level('canvas_node', LogLevel.NONE)
logger.set_module_level('canvas_node', LogLevel[LOG_LEVEL])
logger.configure({
'log_to_file': True,

3
js/config.js Normal file
View File

@@ -0,0 +1,3 @@
// Log level for development.
// Possible values: 'DEBUG', 'INFO', 'WARN', 'ERROR', 'NONE'
export const LOG_LEVEL = 'NONE';

View File

@@ -4,6 +4,7 @@
*/
import {logger, LogLevel} from "../logger.js";
import { LOG_LEVEL } from '../config.js';
/**
* Tworzy obiekt loggera dla modułu z predefiniowanymi metodami
@@ -11,8 +12,8 @@ import {logger, LogLevel} from "../logger.js";
* @param {LogLevel} level - Poziom logowania (domyślnie DEBUG)
* @returns {Object} Obiekt z metodami logowania
*/
export function createModuleLogger(moduleName, level = LogLevel.NONE) {
logger.setModuleLevel(moduleName, level);
export function createModuleLogger(moduleName) {
logger.setModuleLevel(moduleName, LogLevel[LOG_LEVEL]);
return {
debug: (...args) => logger.debug(moduleName, ...args),

3
python/config.py Normal file
View File

@@ -0,0 +1,3 @@
# Log level for development.
# Possible values: 'DEBUG', 'INFO', 'WARN', 'ERROR', 'NONE'
LOG_LEVEL = 'NONE'