topoptlab.log_utils module
- class topoptlab.log_utils.BaseLogger[source]
Bases:
ABCBase class for Loggers and show general structure.
- abstractmethod critical()[source]
Write information due to critical failure. These are “unexpected” errors.
- Return type:
None
- class topoptlab.log_utils.EmptyLogger(**kwargs: Any)[source]
Bases:
BaseLoggerImitates SimpleLogger in terms of the available methods, but never does anything. This is just a placeholder class.
- critical(*args, **kwargs: Any) None[source]
Write information due to critical failure. These are “unexpected” errors.
- Return type:
None
- class topoptlab.log_utils.SimpleLogger(file: str, verbosity: int = 20)[source]
Bases:
BaseLoggerSimple class to allow logging like the logging module, but is much easier to handle. Originally this was written because in IDEs as there logging module continues running in the background even after the program has finished causing errors to occur due to re-initialization and such.
- critical(msg: str) None[source]
Append critical error messages to logfile. These errors are unexpected and mean that either you have entered some nonsense which naturally will lead to strange errors or something that we overlooked.
- Parameters:
msg (str) – message.
- Return type:
None.
- debug(msg: str) None[source]
Append debugging information to logfile.
- Parameters:
msg (str) – message.
- Return type:
None.
- error(msg: str) None[source]
Append error messages to logfile. These errors are “expected” and should stem from invalid combinations or usual things like convergence issues.
- Parameters:
msg (str) – message.
- Return type:
None.
- info(msg: str) None[source]
Append simulation information to logfile.
- Parameters:
msg (str) – message.
- Return type:
None.
- topoptlab.log_utils.init_logging(logfile: str, verbosity: int = 20) SimpleLogger[source]
Initialize the logging and returns a function for the specified logging. This function is right now purely legacy as we have abandoned the native Python logging package. Might be revived later.
- Parameters:
logfile (str) – name of logfile.
verbosity (int) –
verbosity level following the conventions of the logging module with a few extra levels. Please be aware of the slightly strange logic of the logging module: counterintuitively lower numerical values sned more detailed (less severe) messages. e. g. verbosity=10 activates all output while verbosity=20 omits performance and debug messages.
10 : DEBUG detailed iteration or solver info
15 : PERFORMANCE timing or convergence summaries
20 : INFO high-level simulation information
30 : WARNING non-fatal issues
40 : ERROR severe problems
50 : CRITICAL critical failures
- Returns:
logger – Returns the Logger used to write information to logfile.
- Return type:
- topoptlab.log_utils.parse_simple_logfile(path: str) Dict[str, Any][source]
Parse a log file written by SimpleLogger into header information, iteration data, and tagged messages such as [PERF], [DEBUG], etc.
- pathstr
path of logfile.
- log_datadict
dictionary of information of logfile.
Notes
The parser stops collecting header information once it encounters an iteration line (“it.: …”) or any line beginning with a log prefix such as [PERF], [DEBUG], etc.