The console printing class. More...
#include "murl_system_console.h"
Public Types | |
enum | Level { QUIET , ERROR , WARNING , INFO , MAX_LEVELS } |
Definition of the print levels. More... | |
Public Member Functions | |
Console () | |
The default constructor. | |
Console (const String &globalPrefix) | |
Constructor taking a global prefix string. More... | |
Bool | SetLevel (Level level) |
Set the current print level. More... | |
Level | GetLevel () const |
Get the current print level. More... | |
void | SetIndentWidth (UInt32 indentWidth) |
Set the number of indent characters per section. More... | |
UInt32 | GetIndentWidth () const |
Get the number of indent characters per section. More... | |
void | SetIndentChar (Char indentChar) |
Set the indent character. More... | |
Char | GetIndentChar () const |
Get the indent character. More... | |
void | SetGlobalPrefix (const String &prefix) |
Set the global prefix string. More... | |
const String & | GetGlobalPrefix () const |
Get the global prefix string. More... | |
void | SetInfoPrefix (const String &prefix) |
Set the info prefix string. More... | |
const String & | GetInfoPrefix () const |
Get the info prefix string. More... | |
void | SetWarningPrefix (const String &prefix) |
Set the warning prefix string. More... | |
const String & | GetWarningPrefix () const |
Get the warning prefix string. More... | |
void | SetErrorPrefix (const String &prefix) |
Set the error prefix string. More... | |
const String & | GetErrorPrefix () const |
Get the error prefix string. More... | |
UInt32 | GetCurrentSection () const |
Get the current section. More... | |
const String & | GetCurrentIndentString () const |
Get the current indent string. More... | |
Bool | BeginSection (const Char *format,...) |
Begin a section and print formatted variadic arguments. More... | |
Bool | BeginSection (const String &message) |
Begin a section and print a string. More... | |
Bool | BeginSection () |
Begin a section. More... | |
Bool | EndSection (const Char *format,...) |
End a section and print formatted variadic arguments. More... | |
Bool | EndSection (const String &message) |
End a section and print a string. More... | |
Bool | EndSection () |
End a section. More... | |
Bool | PrintInfo (const Char *format,...) const |
Print formatted variadic arguments at info level. More... | |
Bool | PrintInfo (const String &message) const |
Print a string at info level. More... | |
Bool | PrintWarning (const Char *format,...) const |
Print formatted variadic arguments at warning level. More... | |
Bool | PrintWarning (const String &message) const |
Print a string at warning level. More... | |
Bool | PrintError (const Char *format,...) const |
Print formatted variadic arguments at error level. More... | |
Bool | PrintError (const String &message) const |
Print a string at error level. More... | |
Static Public Member Functions | |
static Bool | Print (const Char *format,...) |
Print formatted variadic arguments. More... | |
static Bool | Print (const String &message) |
Print a string. More... | |
static Bool | PrintEndline (const String &message) |
Print a string including an end-of-line character at the end of the string. More... | |
static Bool | PrintHex (const ConstData &data, UInt32 bytesPerLine=16) |
Print the hex dump of a data object. More... | |
Protected Member Functions | |
void | PrintMessage (const String &prefix, const String &message) const |
Print a string with level prefix. More... | |
Protected Attributes | |
Level | mLevel |
The current level. | |
Char | mIndentChar |
The indentation character. | |
UInt32 | mIndentWidth |
The indentation width. | |
UInt32 | mSection |
The section counter. | |
String | mIndentString |
The indentation string cache. | |
String | mGlobalPrefix |
The global prefix string. | |
String | mInfoPrefix |
The info prefix string. | |
String | mWarningPrefix |
The warning prefix string. | |
String | mErrorPrefix |
The error prefix string. | |
Detailed Description
The console printing class.
The console prints to std::printf or ANDROID_LOG_INFO.
The console class has serveral static methods to print without a class context e.g. System::Console::Print().
An instance of the console class can print three levels:
- The information level.
- The warning level.
- The error level.
Printing a message supports:
- A customizable prefix string for each level.
- A customizable global prefix string.
- Nested sections with customizable indentation width and character.
- Suppress printing by setting the current print level.
The output string is: [global prefix]" "[indent string][level prefix]" "[message].
Member Enumeration Documentation
◆ Level
Definition of the print levels.
Use GetLevel() to get the current level.
Enumerator | |
---|---|
QUIET | Do not print. |
ERROR | Print errors only. |
WARNING | Print errors and warnings. |
INFO | Print errors, warnings and infos. |
Constructor & Destructor Documentation
◆ Console()
Murl::System::Console::Console | ( | const String & | globalPrefix | ) |
Constructor taking a global prefix string.
- Parameters
-
globalPrefix The global prefix string.
Member Function Documentation
◆ Print() [1/2]
Print formatted variadic arguments.
- Parameters
-
format The format string. ... The variadic arguments.
- Returns
- true if successful.
Referenced by Murl::Util::Environment::EnumParameter< EnumType >::Process(), and Murl::Util::Environment::EnumArrayParameter< EnumType >::Process().
◆ Print() [2/2]
Print a string.
- Parameters
-
message The message string to print.
- Returns
- true if successful.
◆ PrintEndline()
Print a string including an end-of-line character at the end of the string.
- Parameters
-
message The message string to print.
- Returns
- true if successful.
◆ PrintHex()
|
static |
Print the hex dump of a data object.
- Parameters
-
data The data object to print. bytesPerLine The the number of source bytes per line.
- Returns
- true if successful.
◆ SetLevel()
Set the current print level.
- Parameters
-
level The current print level.
- Returns
- true if successful, false if level is invalid.
◆ GetLevel()
Level Murl::System::Console::GetLevel | ( | ) | const |
Get the current print level.
- Returns
- The current print level.
◆ SetIndentWidth()
void Murl::System::Console::SetIndentWidth | ( | UInt32 | indentWidth | ) |
Set the number of indent characters per section.
The default number of indent characters is 2. The indent string contains the indent character (GetIndentWidth() * GetCurrentSection()) times. The indent string is printed for each message.
- Parameters
-
indentWidth The number of indent characters per section, a width of zero disables indentation.
◆ GetIndentWidth()
UInt32 Murl::System::Console::GetIndentWidth | ( | ) | const |
Get the number of indent characters per section.
- Returns
- The number of indent characters per section.
◆ SetIndentChar()
void Murl::System::Console::SetIndentChar | ( | Char | indentChar | ) |
Set the indent character.
The default indent character is a space. The indent string contains the indent character (GetIndentWidth() * GetCurrentSection()) times. The indent string is printed for each message.
- Parameters
-
indentChar The indent character.
◆ GetIndentChar()
Char Murl::System::Console::GetIndentChar | ( | ) | const |
Get the indent character.
- Returns
- The indent character.
◆ SetGlobalPrefix()
void Murl::System::Console::SetGlobalPrefix | ( | const String & | prefix | ) |
Set the global prefix string.
The global prefix string is printed for each message including a trailing space character.
- Parameters
-
prefix The global prefix string.
◆ GetGlobalPrefix()
const String& Murl::System::Console::GetGlobalPrefix | ( | ) | const |
Get the global prefix string.
- Returns
- The global prefix string.
◆ SetInfoPrefix()
void Murl::System::Console::SetInfoPrefix | ( | const String & | prefix | ) |
Set the info prefix string.
The info prefix string is printed for info messages including a trailing space character.
- Parameters
-
prefix The info prefix string.
◆ GetInfoPrefix()
const String& Murl::System::Console::GetInfoPrefix | ( | ) | const |
Get the info prefix string.
- Returns
- The info prefix string.
◆ SetWarningPrefix()
void Murl::System::Console::SetWarningPrefix | ( | const String & | prefix | ) |
Set the warning prefix string.
The warning prefix string is printed for warning messages including a trailing space character.
- Parameters
-
prefix The warning prefix string.
◆ GetWarningPrefix()
const String& Murl::System::Console::GetWarningPrefix | ( | ) | const |
Get the warning prefix string.
- Returns
- The warning prefix string.
◆ SetErrorPrefix()
void Murl::System::Console::SetErrorPrefix | ( | const String & | prefix | ) |
Set the error prefix string.
The error prefix string is printed for error messages including a trailing space character.
- Parameters
-
prefix The error prefix string.
◆ GetErrorPrefix()
const String& Murl::System::Console::GetErrorPrefix | ( | ) | const |
Get the error prefix string.
- Returns
- The error prefix string.
◆ GetCurrentSection()
UInt32 Murl::System::Console::GetCurrentSection | ( | ) | const |
Get the current section.
The currend section is incremented by BeginInfo() and decremented by EndInfo(). The current section is used for indentation only, see SetIndentChar() and SetIndentWidth().
- Returns
- The current section.
◆ GetCurrentIndentString()
const String& Murl::System::Console::GetCurrentIndentString | ( | ) | const |
Get the current indent string.
The indent string contains the indent character (GetIndentWidth() * GetCurrentSection()) times. The indent string is printed for each message.
- Returns
- The current indent string.
◆ BeginSection() [1/3]
Begin a section and print formatted variadic arguments.
The message is printed before incrementing the current section.
- Parameters
-
format The format string. ... The variadic arguments.
- Returns
- true if successful.
◆ BeginSection() [2/3]
Begin a section and print a string.
The message is printed before incrementing the current section.
- Parameters
-
message The message string to print.
- Returns
- true if successful.
◆ BeginSection() [3/3]
Bool Murl::System::Console::BeginSection | ( | ) |
Begin a section.
Increments the current section.
- Returns
- true if successful.
◆ EndSection() [1/3]
End a section and print formatted variadic arguments.
The message is printed after decrementing the current section.
- Parameters
-
format The format string. ... The variadic arguments.
- Returns
- true if successful.
◆ EndSection() [2/3]
End a section and print a string.
The message is printed after decrementing the current section.
- Parameters
-
message The message string to print.
- Returns
- true if successful.
◆ EndSection() [3/3]
Bool Murl::System::Console::EndSection | ( | ) |
End a section.
Decrements the current section.
- Returns
- true if successful.
◆ PrintInfo() [1/2]
Print formatted variadic arguments at info level.
- Parameters
-
format The format string. ... The variadic arguments.
- Returns
- true if info level is enabled.
◆ PrintInfo() [2/2]
Print a string at info level.
- Parameters
-
message The message string to print.
- Returns
- true if info level is enabled.
◆ PrintWarning() [1/2]
Print formatted variadic arguments at warning level.
- Parameters
-
format The format string. ... The variadic arguments.
- Returns
- true if warning or info level is enabled.
◆ PrintWarning() [2/2]
Print a string at warning level.
- Parameters
-
message The message string to print.
- Returns
- true if warning or info level is enabled.
◆ PrintError() [1/2]
Print formatted variadic arguments at error level.
- Parameters
-
format The format string. ... The variadic arguments.
- Returns
- true if error, warning or info level is enabled.
◆ PrintError() [2/2]
Print a string at error level.
- Parameters
-
message The message string to print.
- Returns
- true if error, warning or info level is enabled.
◆ PrintMessage()
|
protected |
Print a string with level prefix.
- Parameters
-
prefix The level prefix string. message The message string to print.
The documentation for this class was generated from the following file:
- murl_system_console.h