@@ -72,11 +72,29 @@ def emit(self, record: logging.LogRecord) -> None:
72
72
Args:
73
73
record: The logging record to emit
74
74
"""
75
- class_name = record .class_name if hasattr (record , "class_name" ) else record .name # type: ignore has been added as extra attribute in LogRecord
76
- method_name = record .method_name if hasattr (record , "method_name" ) else record .funcName # type: ignore has been added as extra attribute in LogRecord
77
- if self .to_console or (hasattr (record , "to_console" ) and record .to_console ): # type: ignore has been added as extra attribute in LogRecord
78
- _iris .get_iris ().cls ("%SYS.System" ).WriteToConsoleLog (self .format (record ),
79
- 0 ,self .level_map_console .get (record .levelno , 0 ),class_name + "." + method_name )
75
+ # Extract class and method names with fallbacks
76
+ class_name = getattr (record , "class_name" , record .name )
77
+ method_name = getattr (record , "method_name" , record .funcName )
78
+
79
+ # Format message and get full method path
80
+ message = self .format (record )
81
+ method_path = f"{ class_name } .{ method_name } "
82
+
83
+ # Determine if console logging should be used
84
+ use_console = self .to_console or getattr (record , "to_console" , False )
85
+
86
+ if use_console :
87
+ _iris .get_iris ().cls ("%SYS.System" ).WriteToConsoleLog (
88
+ message ,
89
+ 0 ,
90
+ self .level_map_console .get (record .levelno , 0 ),
91
+ method_path
92
+ )
80
93
else :
81
- log_lvl = self .level_map .get (record .levelno , 4 )
82
- _iris .get_iris ().cls ("Ens.Util.Log" ).Log (log_lvl ,class_name , method_name , self .format (record ))
94
+ log_level = self .level_map .get (record .levelno , 4 )
95
+ _iris .get_iris ().cls ("Ens.Util.Log" ).Log (
96
+ log_level ,
97
+ class_name ,
98
+ method_name ,
99
+ message
100
+ )
0 commit comments