LogIt++
|
Structure to store log formatting instructions. More...
#include <PatternCompiler.hpp>
Public Types | |
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 (const std::string &text, const bool &strip_ansi) | |
Constructor for static text. | |
FormatInstruction (const FormatType &type, const int &width=0, const bool &left=false, const bool ¢er=false, const bool &trunc=false, const 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 | |
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 17 of file PatternCompiler.hpp.
|
strong |
Possible types of instructions for log formatting.
Definition at line 21 of file PatternCompiler.hpp.
|
inlineexplicit |
Constructor for static text.
text | The static text. |
strip_ansi | If true, removes ANSI escape codes (e.g., colors). |
Definition at line 82 of file PatternCompiler.hpp.
|
inlineexplicit |
Constructor for other types.
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 93 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 111 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 341 of file PatternCompiler.hpp.
bool logit::FormatInstruction::center_align = false |
Center alignment flag.
Definition at line 75 of file PatternCompiler.hpp.
bool logit::FormatInstruction::left_align = false |
Left alignment flag.
Definition at line 74 of file PatternCompiler.hpp.
std::string logit::FormatInstruction::static_text |
Used only if type == StaticText.
Definition at line 70 of file PatternCompiler.hpp.
bool logit::FormatInstruction::strip_ansi = false |
Removes ANSI escape codes (e.g., colors) if true.
Definition at line 77 of file PatternCompiler.hpp.
bool logit::FormatInstruction::truncate = false |
Truncation flag.
Definition at line 76 of file PatternCompiler.hpp.
FormatType logit::FormatInstruction::type |
The type of the format instruction.
Definition at line 69 of file PatternCompiler.hpp.
int logit::FormatInstruction::width = 0 |
Width for formatting.
Definition at line 73 of file PatternCompiler.hpp.