Skip to content

Commit 63bb7e7

Browse files
committed
Refactor LogManager and IRISLogHandler to rename 'console' parameter to 'to_console' for clarity
1 parent b463aae commit 63bb7e7

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/iop/_log_manager.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ class LogManager:
66
"""Manages logging integration between Python's logging module and IRIS."""
77

88
@staticmethod
9-
def get_logger(class_name: str, method_name: Optional[str] = None, console: bool = False) -> logging.Logger:
9+
def get_logger(class_name: str, method_name: Optional[str] = None, to_console: bool = False) -> logging.Logger:
1010
"""Get a logger instance configured for IRIS integration.
1111
1212
Args:
1313
class_name: Name of the class logging the message
1414
method_name: Optional name of the method logging the message
15-
console: If True, log to the console instead of IRIS
15+
to_console: If True, log to the console instead of IRIS
1616
1717
Returns:
1818
Logger instance configured for IRIS integration
@@ -21,7 +21,7 @@ def get_logger(class_name: str, method_name: Optional[str] = None, console: bool
2121

2222
# Only add handler if none exists
2323
if not logger.handlers:
24-
handler = IRISLogHandler(class_name, method_name, console)
24+
handler = IRISLogHandler(class_name, method_name, to_console)
2525
formatter = logging.Formatter('%(message)s')
2626
handler.setFormatter(formatter)
2727
logger.addHandler(handler)
@@ -33,7 +33,7 @@ def get_logger(class_name: str, method_name: Optional[str] = None, console: bool
3333
class IRISLogHandler(logging.Handler):
3434
"""Custom logging handler that routes Python logs to IRIS logging system."""
3535

36-
def __init__(self, class_name: str, method_name: Optional[str] = None, console: bool = False):
36+
def __init__(self, class_name: str, method_name: Optional[str] = None, to_console: bool = False):
3737
"""Initialize the handler with context information.
3838
3939
Args:
@@ -44,7 +44,7 @@ def __init__(self, class_name: str, method_name: Optional[str] = None, console:
4444
super().__init__()
4545
self.class_name = class_name
4646
self.method_name = method_name
47-
self.console = console
47+
self.to_console = to_console
4848

4949
def format(self, record: logging.LogRecord) -> str:
5050
"""Format the log record into a string.
@@ -55,7 +55,7 @@ def format(self, record: logging.LogRecord) -> str:
5555
Returns:
5656
Formatted log message
5757
"""
58-
if self.console:
58+
if self.to_console:
5959
return f"{record}"
6060
return record.getMessage()
6161

@@ -75,7 +75,7 @@ def emit(self, record: logging.LogRecord) -> None:
7575
}
7676

7777
log_func = level_map.get(record.levelno, iris.cls("Ens.Util.Log").LogInfo)
78-
if self.console or (hasattr(record, "to_console") and record.to_console):
78+
if self.to_console or (hasattr(record, "to_console") and record.to_console):
7979
iris.cls("%SYS.System").WriteToConsoleLog(self.format(record),0,0,"IoP.Log")
8080
else:
8181
log_func(self.class_name, self.method_name, self.format(record))

0 commit comments

Comments
 (0)