4.1.1.9.1.7. pyfem.util.logger module
- setLogger(props: Any) Logger[source]
Create and configure the root logger for the current analysis.
The function expects a configuration object which may provide a logger.level attribute (e.g. a namespace or simple object). The returned logger is the root logger configured with a single stream handler according to the requested verbosity.
- Parameters:
props – Configuration object (may have a logger attribute with .level).
- Returns:
Configured root logger.
- Return type:
logging.Logger
- Raises:
NotImplementedError – If an unsupported level string is provided.
- getLogger() Logger[source]
Return the active root logger instance.
- Returns:
The active root logger.
- Return type:
logging.Logger
- separator(symbol: str = '-', level: str = 'info') None[source]
Log a horizontal separator line consisting of two leading spaces followed by 81 copies of symbol.
The separator is emitted using the root logger’s INFO level so it respects the currently configured logging output format and level.
- Parameters:
symbol – Single-character string used to draw the separator. Defaults to ‘-‘.
- logVariable(description: str, value: Any, width: int = 35, level: str = 'info') None[source]
Log a variable in a formatted way with aligned colons.
Prints in the format: “[description] …………. : [value]” where the colon is always at the same position determined by width.
- Parameters:
description – Description text for the variable (left side).
value – Value to display (right side of colon).
width – Total width for description + dots before colon. Defaults to 35.
level – Logging level (“info” or “debug”). Defaults to “info”.
Examples
>>> logVariable("Number of nodes", 100) Number of nodes ............... : 100 >>> logVariable("Young's modulus", 210e9, width=40) Young's modulus ........................ : 210000000000.0
- logHeader(left_text: str, right_text: str, width: int = 35, level: str = 'info') None[source]
Log two strings with aligned spacing similar to logVariable.
Prints in the format: “[left_text] …………. : [right_text]” where the colon is always at the same position determined by width.
- Parameters:
left_text – Text to display on the left side.
right_text – Text to display on the right side of colon.
width – Total width for left text + dots before colon. Defaults to 35.
level – Logging level (“info” or “debug”). Defaults to “info”.
Examples
>>> logHeader("Parameter", "Value") Parameter ......................... : Value >>> logHeader("Solver type", "Nonlinear", width=40) Solver type ............................ : Nonlinear