@@ -16,18 +16,19 @@ class SimLogger:
1616 """
1717 Provides log of events as the simulation runs.
1818
19- Attributes:
20- log_to_console (boolean):
21- Whether to print log messages to the console.
22- log_to_file (boolean):
23- Whether to save log to a file.
24- file_path (str):
25- Path to save log to file.
26- sanitise (boolean):
27- Whether to sanitise dictionaries to remove memory addresses in
28- logs, default False.
29- logger (logging.Logger):
30- The logging instance used for logging messages.
19+ Attributes
20+ ----------
21+ log_to_console : boolean
22+ Whether to print log messages to the console.
23+ log_to_file : boolean
24+ Whether to save log to a file.
25+ file_path : str
26+ Path to save log to file.
27+ sanitise : boolean
28+ Whether to sanitise dictionaries to remove memory addresses in logs,
29+ default False.
30+ logger : logging.Logger
31+ The logging instance used for logging messages.
3132 """
3233 def __init__ (self , log_to_console = False , log_to_file = False ,
3334 file_path = ("../outputs/logs/" +
@@ -36,18 +37,19 @@ def __init__(self, log_to_console=False, log_to_file=False,
3637 """
3738 Initialise the Logger class.
3839
39- Arguments:
40- log_to_console (boolean):
41- Whether to print log messages to the console.
42- log_to_file (boolean):
43- Whether to save log to a file.
44- file_path (str):
45- Path to save log to file. Note, if you use an existing .log
46- file name, it will append to that log. Defaults to filename
47- based on current date and time, and folder "../outputs/log/".
48- sanitise (boolean):
49- Whether to sanitise dictionaries to remove memory addresses
50- in logs, default False.
40+ Parameters
41+ ----------
42+ log_to_console : boolean
43+ Whether to print log messages to the console.
44+ log_to_file : boolean
45+ Whether to save log to a file.
46+ file_path : str
47+ Path to save log to file. Note, if you use an existing .log
48+ file name, it will append to that log. Defaults to filename
49+ based on current date and time, and folder "../outputs/log/".
50+ sanitise : boolean
51+ Whether to sanitise dictionaries to remove memory addresses in
52+ logs, default False.
5153 """
5254 self .log_to_console = log_to_console
5355 self .log_to_file = log_to_file
@@ -69,8 +71,10 @@ def _validate_log_path(self):
6971 """
7072 Validate the log file path.
7173
72- Raises:
73- ValueError: If log path is invalid.
74+ Raises
75+ ------
76+ ValueError
77+ If log path is invalid.
7478 """
7579 # Check if directory exists
7680 directory = os .path .dirname (self .file_path )
@@ -123,15 +127,16 @@ def sanitise_object(self, obj):
123127 """
124128 Sanitise object references to avoid memory addresses in logs.
125129
126- Arguments:
127- obj (object):
128- Object to sanitise
130+ Parameters
131+ ----------
132+ obj : object
133+ Object to sanitise
129134
130- Returns:
131- str:
132- Sanitised version of the object. If it"s an object,
133- it returns the class name; otherwise , it returns the
134- object itself.
135+ Returns
136+ -------
137+ str
138+ Sanitised version of the object. If it"s an object , it returns the
139+ class name; otherwise, it returns the object itself.
135140 """
136141 # Only sanitise custom objects (not basic types like int, str, etc.)
137142 if isinstance (obj , object ) and not isinstance (
@@ -145,11 +150,12 @@ def log(self, msg, sim_time=None):
145150 """
146151 Log a message if logging is enabled.
147152
148- Arguments:
149- msg (str):
150- Message to log.
151- sim_time (float|None, optional):
152- Current simulation time. If provided, prints before message.
153+ Parameters
154+ ----------
155+ msg : str
156+ Message to log.
157+ sim_time : float or None
158+ Current simulation time. If provided, prints before message.
153159 """
154160 # Sanitise (if enabled) and pretty format dictionaries
155161 if isinstance (msg , dict ):
0 commit comments