Console
C++:
phynexis::utils::consolePython:phynexis.utilsHeader:src/utils/console.hpp
Console logging and output control for phynexis. Supports leveled output (debug/info/warning/error/fatal), colorized terminal output, timestamps, and MPI rank display.
Level
C++:
phynexis::utils::console::LevelPython:phynexis.utils.Level
Enum controlling the minimum log level for output filtering.
| Value | Numeric | Description |
|---|---|---|
Level.DEBUG | 0 | Debug messages |
Level.INFO | 1 | Informational messages (default minimum) |
Level.WARNING | 2 | Warning messages |
Level.ERROR | 3 | Error messages |
Level.FATAL | 4 | Fatal error messages |
MPIOutputMode
C++:
phynexis::utils::console::MPIOutputModePython:phynexis.utils.MPIOutputMode
Enum controlling MPI output behavior.
| Value | Description |
|---|---|
MPIOutputMode.ONLY_MASTER | Only rank 0 outputs (default) |
MPIOutputMode.ALL_WITH_RANK | All ranks output with rank prefix |
Config
C++:
phynexis::utils::console::ConfigPython:phynexis.utils.Config
Configuration object controlling the appearance and filtering of console output.
Constructor
Config()
Creates a config with default settings (min_level=info, timestamps on, colors on).
Static Methods
Config.debug()
Create a Config with min_level=DEBUG for verbose debugging output.
Config.release()
Create a Config with min_level=WARNING for production/release output (only warnings and above).
Config.verbose()
Create a Config with min_level=DEBUG and show_location=True for detailed debug output.
Properties
| Property | Type | Access | Description |
|---|---|---|---|
min_level | Level | read/write | Minimum log level to display |
show_timestamp | bool | read/write | Show timestamps in output |
show_level | bool | read/write | Show level tag (INFO, WARN, etc.) |
show_location | bool | read/write | Show file/line location |
color_output | bool | read/write | Enable ANSI color codes |
show_rank | bool | read/write | Show MPI rank prefix |
Methods
set_min_level(level)
Set minimum display level. Returns the Config object for chaining.
Parameters:
| Parameter | Type | Description |
|---|---|---|
level | Level | Minimum level to display |
set_show_timestamp(enabled)
Toggle timestamp display. Returns the Config object for chaining.
set_show_level(enabled)
Toggle level tag display. Returns the Config object for chaining.
set_show_location(enabled)
Toggle source location display. Returns the Config object for chaining.
set_color_output(enabled)
Toggle colorized output. Returns the Config object for chaining.
set_show_rank(enabled)
Toggle MPI rank prefix display. Returns the Config object for chaining.
Example:
import phynexis
cfg = phynexis.utils.custom()
cfg.show_timestamp = False
cfg.color_output = False
phynexis.utils.info("no timestamp, no color")
# Config factory methods
debug_cfg = phynexis.utils.Config.debug()
release_cfg = phynexis.utils.Config.release()
print("debug min_level:", debug_cfg.min_level)
print("release min_level:", release_cfg.min_level)
Output:
[INFO] no timestamp, no color
debug min_level: Level.DEBUG
release min_level: Level.WARNING
Logging Functions
Module-level functions for leveled console output.
debug(msg)
Print a debug-level message. Only visible when min_level ≤ 0.
info(msg)
Print an info-level message.
plain(msg)
Print a plain message without any level prefix or formatting.
warning(msg)
Print a warning-level message.
error(msg)
Print an error-level message.
fatal(msg)
Print a fatal-level message and terminate.
Parameters:
| Parameter | Type | Description |
|---|---|---|
msg | str | Message string to print |
Broadcast Variants
Each level has an _all variant that broadcasts to all MPI ranks:
debug_all(msg)info_all(msg)warning_all(msg)error_all(msg)fatal_all(msg)
Example:
import phynexis
phynexis.utils.info("simulation started")
phynexis.utils.debug("debug info: dt=1e-5")
phynexis.utils.warning("mesh quality low")
phynexis.utils.plain("raw output without prefix")
Output:
[INFO] [12:01:05.232] simulation started
[DEBUG] [12:01:05.233] debug info: dt=1e-5
[WARNING] [12:01:05.233] mesh quality low
raw output without prefix
Control Functions
set_level(level)
Set the global minimum log level.
Parameters:
| Parameter | Type | Description |
|---|---|---|
level | Level | Minimum level, e.g. Level.WARNING |
set_verbose(enabled)
Enable or disable verbose (debug) output. Equivalent to set_level(0).
set_color(enabled)
Enable or disable colorized output globally.
custom()
Return a reference to the global Config object. Modifications to the returned object take effect immediately.
Returns: Config — global configuration (mutable reference)
Example:
import phynexis
phynexis.utils.set_level(phynexis.utils.Level.WARNING) # Only warning and above
phynexis.utils.info("hidden")
phynexis.utils.warning("visible")
Output:
[WARNING] visible