RichConsoleStyleMessageFormatter
The RichConsoleStyleMessageFormatter class The class implement a message formatter dedicated to console pretty printing on a console Among other thing it feature formatting using a markdown like syntax: - color rendering, 'italics' or *italics* - alignment and wrapping for long message that are then much easier to read. - automatic reading of the console number of column for prettier display.
The `RichConsoleStyleMessageFormatter` class enhances console logging by providing rich text formatting capabilities such as color rendering, italics, alignment, and text wrapping based on the console width.
- module
- Sofa.framework.Core
- namespace
- sofa::helper::logging
- include
- sofa/core/logging/RichConsoleStyleMessageFormatter.h
- inherits
-
- MessageFormatter
- description
The RichConsoleStyleMessageFormatter class in the SOFA framework is primarily designed to enhance console logging by providing rich text formatting for messages. It does not contribute to any specific governing equations or operators related to finite element analysis, constitutive laws, kinematic laws, numerical methods, or discretization choices used in computational mechanics simulations. Instead, it focuses on improving the readability and presentation of log messages output to a console. The class implements the MessageFormatter interface and provides the following functionalities:
- Text Formatting: It supports formatting text with features such as color rendering (e.g., blue for component names), italics using both single quotes ('italics') and asterisks (italics), and automatic alignment of messages based on a prefix size.
- Text Wrapping: Long messages are wrapped to fit the console width, improving readability by breaking lines at appropriate points within the text.
- File Information Display: If enabled, it can display file information (filename and line number) where the message was emitted, which is useful for debugging purposes.
- Singleton Instance: Provides a singleton instance through
getInstanceto ensure consistent formatting across different parts of the SOFA application.
The primary method, formatMessage, takes a Message object and an output stream (std::ostream) and formats the message according to the specified rules before writing it to the console. The formatter ensures that messages are aligned with their prefix (based on the message type) and rendered in appropriate colors for different types of log messages.
In summary, while this class is integral to enhancing user experience by improving logging output readability, it does not play a role in the mathematical or physical aspects of FEM simulations within SOFA.
Methods
RichConsoleStyleMessageFormatter &
getInstance
()
void
formatMessage
(const Message & m, int & out)
{
"name": "RichConsoleStyleMessageFormatter",
"namespace": "sofa::helper::logging",
"module": "Sofa.framework.Core",
"include": "sofa/core/logging/RichConsoleStyleMessageFormatter.h",
"doc": "The RichConsoleStyleMessageFormatter class\n The class implement a message formatter dedicated to console pretty printing on a console\n Among other thing it feature formatting using a markdown like syntax:\n - color rendering, 'italics' or *italics*\n - alignment and wrapping for long message that are then much easier to read.\n - automatic reading of the console number of column for prettier display.",
"inherits": [
"MessageFormatter"
],
"templates": [],
"data_fields": [],
"links": [],
"methods": [
{
"name": "getInstance",
"return_type": "RichConsoleStyleMessageFormatter &",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": true,
"access": "public"
},
{
"name": "formatMessage",
"return_type": "void",
"params": [
{
"name": "m",
"type": "const Message &"
},
{
"name": "out",
"type": "int &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
}
],
"description": "The `RichConsoleStyleMessageFormatter` class in the SOFA framework is designed to enhance console logging by providing pretty-printing capabilities for messages. It extends the `MessageFormatter` interface and implements methods to format messages with features such as color rendering, italics (using 'italics' or *italics* syntax), alignment, and text wrapping based on the console width.\n\nThe primary method of this class is `formatMessage`, which takes a `Message` object and an output stream (`std::ostream`) to write the formatted message. The formatting includes aligning the prefix text (based on the message type) with the rest of the message, rendering colors for different message types, and wrapping long messages for better readability.\n\nThis formatter also supports displaying file information (file name and line number) if enabled, which can be useful for debugging purposes.\n\nThe class provides a singleton instance through the `getInstance` method, ensuring consistent formatting across different parts of the SOFA application.",
"maths": "The `RichConsoleStyleMessageFormatter` class in the SOFA framework is primarily designed to enhance console logging by providing rich text formatting for messages. It does not contribute to any specific governing equations or operators related to finite element analysis, constitutive laws, kinematic laws, numerical methods, or discretization choices used in computational mechanics simulations. Instead, it focuses on improving the readability and presentation of log messages output to a console. The class implements the `MessageFormatter` interface and provides the following functionalities:\n\n1. **Text Formatting**: It supports formatting text with features such as color rendering (e.g., blue for component names), italics using both single quotes ('italics') and asterisks (*italics*), and automatic alignment of messages based on a prefix size.\n2. **Text Wrapping**: Long messages are wrapped to fit the console width, improving readability by breaking lines at appropriate points within the text.\n3. **File Information Display**: If enabled, it can display file information (filename and line number) where the message was emitted, which is useful for debugging purposes.\n4. **Singleton Instance**: Provides a singleton instance through `getInstance` to ensure consistent formatting across different parts of the SOFA application.\n\nThe primary method, `formatMessage`, takes a `Message` object and an output stream (`std::ostream`) and formats the message according to the specified rules before writing it to the console. The formatter ensures that messages are aligned with their prefix (based on the message type) and rendered in appropriate colors for different types of log messages.\n\nIn summary, while this class is integral to enhancing user experience by improving logging output readability, it does not play a role in the mathematical or physical aspects of FEM simulations within SOFA.",
"abstract": "The `RichConsoleStyleMessageFormatter` class enhances console logging by providing rich text formatting capabilities such as color rendering, italics, alignment, and text wrapping based on the console width.",
"sheet": "\n# RichConsoleStyleMessageFormatter\n\n## Overview\n\nThe `RichConsoleStyleMessageFormatter` class in the SOFA framework is designed to enhance console logging by providing pretty-printing capabilities for messages. It extends the `MessageFormatter` interface and implements methods to format messages with features such as color rendering, italics (using 'italics' or *italics* syntax), alignment, and text wrapping based on the console width.\n\n## Parameters and Data\n\nThe `RichConsoleStyleMessageFormatter` class does not expose any significant data fields. It relies on its methods to format messages according to predefined rules and does not require additional configuration parameters for its operation."
}