![]() |
LogIt++
|
Structure to store log formatting instructions. More...
#include <PatternCompiler.hpp>
Public Types | |
| enum class | CompileContext { Default , NoArgsFallback } |
| Compilation context for handling special cases, such as when arguments are missing. More... | |
| enum class | FormatType { StaticText , Year , Month , Day , Hour , Minute , Second , Millisecond , TwoDigitYear , DateTime , ShortDate , TimeISO8601 , DateISO8601 , TimeStamp , MilliSecondTimeStamp , AbbreviatedMonthName , FullMonthName , AbbreviatedWeekdayName , FullWeekdayName , LogLevel , ShortLogLevel , FileName , FullFileName , SourceFileAndLine , LineNumber , FunctionName , ThreadId , StartColor , EndColor , Message } |
| Possible types of instructions for log formatting. More... | |
Public Member Functions | |
| FormatInstruction (CompileContext context, const std::string &text, bool strip_ansi) | |
| Constructor for static text. | |
| FormatInstruction (CompileContext context, FormatType type, int width=0, bool left=false, bool center=false, bool trunc=false, bool strip_ansi=false) | |
| Constructor for other types. | |
| template<class StreamType> | |
| void | apply (StreamType &oss, const LogRecord &record, const time_shield::DateTimeStruct &dt) const |
| Apply formatting considering alignment and width. | |
Public Attributes | |
| CompileContext | context |
| Compilation context, e.g., default or handling no-argument cases. | |
| FormatType | type |
| The type of the format instruction. | |
| std::string | static_text |
| Used only if type == StaticText. | |
| int | width = 0 |
| Width for formatting. | |
| bool | left_align = false |
| Left alignment flag. | |
| bool | center_align = false |
| Center alignment flag. | |
| bool | truncate = false |
| Truncation flag. | |
| bool | strip_ansi = false |
| Removes ANSI escape codes (e.g., colors) if true. | |
Private Member Functions | |
| std::string | remove_ansi_escape_codes (const std::string &input) const |
| Removes ANSI escape codes (including color codes and cursor movement) from a string. | |
Structure to store log formatting instructions.
Definition at line 19 of file PatternCompiler.hpp.
|
strong |
Compilation context for handling special cases, such as when arguments are missing.
| Enumerator | |
|---|---|
| Default | Standard behavior without modifications. |
| NoArgsFallback | Handle a special pattern for cases with no arguments. |
Definition at line 23 of file PatternCompiler.hpp.
|
strong |
Possible types of instructions for log formatting.
Definition at line 30 of file PatternCompiler.hpp.
|
inlineexplicit |
Constructor for static text.
| context | Compilation context for handling special cases. |
| text | The static text. |
| strip_ansi | If true, removes ANSI escape codes (e.g., colors). |
Definition at line 93 of file PatternCompiler.hpp.
|
inlineexplicit |
Constructor for other types.
| context | Compilation context for handling special cases. |
| type | The format type. |
| width | The width for formatting. |
| left | Left alignment flag. |
| center | Center alignment flag. |
| trunc | Truncation flag. |
| strip_ansi | If true, removes ANSI escape codes (e.g., colors). |
Definition at line 108 of file PatternCompiler.hpp.
|
inline |
Apply formatting considering alignment and width.
| StreamType | The type of the output stream. |
| oss | The output stream. |
| record | The log record. |
| dt | The date and time structure. |
Definition at line 127 of file PatternCompiler.hpp.
|
inlineprivate |
Removes ANSI escape codes (including color codes and cursor movement) from a string.
| input | The input string containing possible ANSI escape codes. |
Definition at line 415 of file PatternCompiler.hpp.
| bool logit::FormatInstruction::center_align = false |
Center alignment flag.
Definition at line 85 of file PatternCompiler.hpp.
| CompileContext logit::FormatInstruction::context |
Compilation context, e.g., default or handling no-argument cases.
Definition at line 78 of file PatternCompiler.hpp.
| bool logit::FormatInstruction::left_align = false |
Left alignment flag.
Definition at line 84 of file PatternCompiler.hpp.
| std::string logit::FormatInstruction::static_text |
Used only if type == StaticText.
Definition at line 80 of file PatternCompiler.hpp.
| bool logit::FormatInstruction::strip_ansi = false |
Removes ANSI escape codes (e.g., colors) if true.
Definition at line 87 of file PatternCompiler.hpp.
| bool logit::FormatInstruction::truncate = false |
Truncation flag.
Definition at line 86 of file PatternCompiler.hpp.
| FormatType logit::FormatInstruction::type |
The type of the format instruction.
Definition at line 79 of file PatternCompiler.hpp.
| int logit::FormatInstruction::width = 0 |
Width for formatting.
Definition at line 83 of file PatternCompiler.hpp.