The console printing class. More...

#include "murl_system_console.h"

Public Types

enum  Level { QUIET, ERROR, WARNING, INFO }
 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 StringGetGlobalPrefix () const
 Get the global prefix string. More...
 
void SetInfoPrefix (const String &prefix)
 Set the info prefix string. More...
 
const StringGetInfoPrefix () const
 Get the info prefix string. More...
 
void SetWarningPrefix (const String &prefix)
 Set the warning prefix string. More...
 
const StringGetWarningPrefix () const
 Get the warning prefix string. More...
 
void SetErrorPrefix (const String &prefix)
 Set the error prefix string. More...
 
const StringGetErrorPrefix () const
 Get the error prefix string. More...
 
UInt32 GetCurrentSection () const
 Get the current section. More...
 
const StringGetCurrentIndentString () 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. More...
 
Char mIndentChar
 The indentation character. More...
 
UInt32 mIndentWidth
 The indentation width. More...
 
UInt32 mSection
 The section counter. More...
 
String mIndentString
 The indentation string cache. More...
 
String mGlobalPrefix
 The global prefix string. More...
 
String mInfoPrefix
 The info prefix string. More...
 
String mWarningPrefix
 The warning prefix string. More...
 
String mErrorPrefix
 The error prefix string. More...
 

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
globalPrefixThe global prefix string.

Member Function Documentation

◆ Print() [1/2]

static Bool Murl::System::Console::Print ( const Char format,
  ... 
)
static

Print formatted variadic arguments.

Parameters
formatThe 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]

static Bool Murl::System::Console::Print ( const String message)
static

Print a string.

Parameters
messageThe message string to print.
Returns
true if successful.

◆ PrintEndline()

static Bool Murl::System::Console::PrintEndline ( const String message)
static

Print a string including an end-of-line character at the end of the string.

Parameters
messageThe message string to print.
Returns
true if successful.

◆ PrintHex()

static Bool Murl::System::Console::PrintHex ( const ConstData data,
UInt32  bytesPerLine = 16 
)
static

Print the hex dump of a data object.

Parameters
dataThe data object to print.
bytesPerLineThe the number of source bytes per line.
Returns
true if successful.

◆ SetLevel()

Bool Murl::System::Console::SetLevel ( Level  level)

Set the current print level.

Parameters
levelThe 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
indentWidthThe 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
indentCharThe 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
prefixThe 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
prefixThe 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
prefixThe 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
prefixThe 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]

Bool Murl::System::Console::BeginSection ( const Char format,
  ... 
)

Begin a section and print formatted variadic arguments.

The message is printed before incrementing the current section.

Parameters
formatThe format string.
...The variadic arguments.
Returns
true if successful.

◆ BeginSection() [2/3]

Bool Murl::System::Console::BeginSection ( const String message)

Begin a section and print a string.

The message is printed before incrementing the current section.

Parameters
messageThe 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]

Bool Murl::System::Console::EndSection ( const Char format,
  ... 
)

End a section and print formatted variadic arguments.

The message is printed after decrementing the current section.

Parameters
formatThe format string.
...The variadic arguments.
Returns
true if successful.

◆ EndSection() [2/3]

Bool Murl::System::Console::EndSection ( const String message)

End a section and print a string.

The message is printed after decrementing the current section.

Parameters
messageThe 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]

Bool Murl::System::Console::PrintInfo ( const Char format,
  ... 
) const

Print formatted variadic arguments at info level.

Parameters
formatThe format string.
...The variadic arguments.
Returns
true if info level is enabled.

◆ PrintInfo() [2/2]

Bool Murl::System::Console::PrintInfo ( const String message) const

Print a string at info level.

Parameters
messageThe message string to print.
Returns
true if info level is enabled.

◆ PrintWarning() [1/2]

Bool Murl::System::Console::PrintWarning ( const Char format,
  ... 
) const

Print formatted variadic arguments at warning level.

Parameters
formatThe format string.
...The variadic arguments.
Returns
true if warning or info level is enabled.

◆ PrintWarning() [2/2]

Bool Murl::System::Console::PrintWarning ( const String message) const

Print a string at warning level.

Parameters
messageThe message string to print.
Returns
true if warning or info level is enabled.

◆ PrintError() [1/2]

Bool Murl::System::Console::PrintError ( const Char format,
  ... 
) const

Print formatted variadic arguments at error level.

Parameters
formatThe format string.
...The variadic arguments.
Returns
true if error, warning or info level is enabled.

◆ PrintError() [2/2]

Bool Murl::System::Console::PrintError ( const String message) const

Print a string at error level.

Parameters
messageThe message string to print.
Returns
true if error, warning or info level is enabled.

◆ PrintMessage()

void Murl::System::Console::PrintMessage ( const String prefix,
const String message 
) const
protected

Print a string with level prefix.

Parameters
prefixThe level prefix string.
messageThe message string to print.

Member Data Documentation

◆ mLevel

Level Murl::System::Console::mLevel
protected

The current level.

◆ mIndentChar

Char Murl::System::Console::mIndentChar
protected

The indentation character.

◆ mIndentWidth

UInt32 Murl::System::Console::mIndentWidth
protected

The indentation width.

◆ mSection

UInt32 Murl::System::Console::mSection
protected

The section counter.

◆ mIndentString

String Murl::System::Console::mIndentString
protected

The indentation string cache.

◆ mGlobalPrefix

String Murl::System::Console::mGlobalPrefix
protected

The global prefix string.

◆ mInfoPrefix

String Murl::System::Console::mInfoPrefix
protected

The info prefix string.

◆ mWarningPrefix

String Murl::System::Console::mWarningPrefix
protected

The warning prefix string.

◆ mErrorPrefix

String Murl::System::Console::mErrorPrefix
protected

The error prefix string.


The documentation for this class was generated from the following file:
  • murl_system_console.h


Copyright © 2011-2018 Spraylight GmbH.