CTR Pia  4.11.3
Game Communication Engine
nn::pia::common::Log Class Reference

This class is used for logging. More...

+ Inheritance diagram for nn::pia::common::Log:

Public Member Functions

 Log (void)
 The constructor. Objects are constructed with all bits of the log level bit mask set to 1.
 
 Log (u32 mask)
 The constructor. A mask representing the log level can be specified as a parameter. More...
 
 ~Log ()
 The destructor.
 
bool IsFlagSet (u64 flag) const
 Indicates whether the specified flags are set. More...
 
bool IsPrintTime () const
 Gets whether time display is enabled or disabled. More...
 
void ResetBaseTime ()
 Resets the base time for the time display to the current time.
 
void SetMask (u32 mask)
 Sets the mask. This allows you to suppress log messages of a particular level. More...
 
void SetPrintTime (bool isPrint)
 Enables and disables the time display. More...
 

Static Public Member Functions

static LogGetGlobalObject (void)
 Gets a pointer to the Log object set using SetGlobalObject(). More...
 
static void SetGlobalObject (Log *pLog)
 Registers a global log object. More...
 

Static Public Attributes

static const u32 LEVEL_ALWAYS = 0x00000001 << 5
 Specifies the log level that is constantly displayed.
 
static const u32 LEVEL_DEBUG = 0x00000001 << 0
 Specifies the debug information level used inside Pia.
 
static const u32 LEVEL_ERROR = 0x00000001 << 3
 Specifies the error level (recoverable).
 
static const u32 LEVEL_FATAL = 0x00000001 << 4
 Specifies the error level (irrecoverable).
 
static const u32 LEVEL_INFO = 0x00000001 << 1
 Specifies the detailed information level used inside Pia.
 
static const u32 LEVEL_WARNING = 0x00000001 << 2
 Specifies the warning level. (This should be changed, but can be ignored.)
 

Detailed Description

This class is used for logging.

You can set a level for the log and switch between showing and hiding the log for each level.


Revision History:

2015-06-19 Added the PIA_LOG_EX() macro.

2012-05-30 Times can now also be printed.

2012-05-30 Made the Write() function private.

2012-04-19 Initial version.

Constructor & Destructor Documentation

nn::pia::common::Log::Log ( u32  mask)
explicit

The constructor. A mask representing the log level can be specified as a parameter.

Parameters
[in]maskSpecifies a bit mask representing the log level.

Member Function Documentation

static Log* nn::pia::common::Log::GetGlobalObject ( void  )
inlinestatic

Gets a pointer to the Log object set using SetGlobalObject().

Calling nn::pia::common::Initialize() implicitly creates a Log instance internally and sets this instance as the global log object.

Returns
Returns a pointer to the instance registered as the global log object.
bool nn::pia::common::Log::IsFlagSet ( u64  flag) const
inline

Indicates whether the specified flags are set.

The result of IsFlagSet(TRACE_FLAG_NEVER) is true.

Returns
Returns true if the particular flag is set, or false otherwise.
Parameters
[in]flagSpecifies the trace flags to query.
bool nn::pia::common::Log::IsPrintTime ( ) const
inline

Gets whether time display is enabled or disabled.

Returns
Returns true if times are printed.
static void nn::pia::common::Log::SetGlobalObject ( Log pLog)
inlinestatic

Registers a global log object.

This function registers the specified Log object as a global log object. The PIA_LOG() macro outputs a log using the Log object registered by this function.

Parameters
[in]pLogSpecifies a pointer to the Log object to be registered.
void nn::pia::common::Log::SetMask ( u32  mask)
inline

Sets the mask. This allows you to suppress log messages of a particular level.

This member function allows you to filter log information being output. Note that a log for which LEVEL_ALWAYS has been specified is always output regardless of the mask set by this member function.

Parameters
[in]maskSpecifies a bit mask representing the log level.
void nn::pia::common::Log::SetPrintTime ( bool  isPrint)
inline

Enables and disables the time display.

When enabled, it displays the time passed from the base time in units of milliseconds, such as "[Pia:12345]..."

Parameters
[in]isPrintSpecify true to display the time.