dgamore.dga_logger#
MPI-aware logging. DgaLogger timestamps messages and, by default, only emits them on the root rank so
that parallel runs produce a single clean log stream.
- class dgamore.dga_logger.DgaLogger(comm: mpi4py.MPI.Comm, output_path: str = './', filename: str = 'dga.log')[source]#
Bases:
objectHandles logging messages in a distributed environment using MPI. Currently, it logs messages to stdout.
- property current_time: str#
The current wall-clock time as a formatted string.
- Returns:
The current wall-clock time formatted as
"YYYY-MM-DD HH:MM:SS.sss".
- debug(message: str, allowed_ranks: tuple = (0,))[source]#
Logs a debug message. This is intended for detailed debugging information that is not usually needed in production.
- info(message: str, allowed_ranks: tuple = (0,))[source]#
Logs an informational message. This is intended for general information about the program’s execution.
- property is_root: bool#
Whether the current process is the root rank.
- Returns:
True if the current MPI rank is the root rank (rank 0).
- log_memory_usage(obj_name: str, obj, n_exists: int = 1, allowed_ranks: tuple = (0,))[source]#
Logs the memory usage of an object in gigabytes. This is useful for tracking memory consumption in distributed applications, especially when using MPI.
- Parameters:
obj_name (str) – Human-readable name used in the log line.
obj – An object exposing
memory_usage_in_gb(e.g. anyIHaveMat); ignored if None.n_exists (int) – Multiplicity factor, i.e. how many such objects exist (the reported size is scaled by it).
allowed_ranks (tuple) – The MPI rank(s) permitted to emit this message.
- Returns:
None.