ConsoleLogger Class Reference

#include <consoleLogger.h>

Inheritance diagram for ConsoleLogger:

Inheritance graph
[legend]
List of all members.

Detailed Description

A class designed to be used as a console consumer and log the data it receives to a file.


Public Member Functions

 DECLARE_CONOBJECT (ConsoleLogger)
bool processArguments (S32 argc, const char **argv)
 Console constructor.
 ConsoleLogger ()
 Default constructor, make sure to initalize.
 ConsoleLogger (const char *fileName, bool append=false)
 Constructor.
 ~ConsoleLogger ()
 Destructor.
bool attach ()
 Attach to the console and begin logging.
bool detach ()
 Detach from the console and stop logging.
void setLogLevel (ConsoleLogEntry::Level level)
 Sets the level of console messages to log.
ConsoleLogEntry::Level getLogLevel () const
 Returns the level of console messages to log.

Static Public Member Functions

static void initPersistFields ()
 Register dynamic fields in a subclass of ConsoleObject.
static void logCallback (ConsoleLogEntry::Level level, const char *consoleLine)
 The callback for the console consumer.

Public Attributes

ConsoleLogEntry::Level mLevel
 The level of log messages to log.

Private Types

typedef SimObject Parent

Private Member Functions

void log (const char *consoleLine)
 The log function called by the consumer callback.
bool init ()
 Utility function, sets up the object (for script interface) returns true if successful.

Private Attributes

bool mLogging
 True if it is currently consuming and logging.
FileStream mStream
 File stream this object writes to.
bool mAppend
 If false, it will clear the file before logging to it.
StringTableEntry mFilename
 The file name to log to.

Static Private Attributes

static bool smInitialized
 This is for use with the default constructor.
static Vector< ConsoleLogger * > mActiveLoggers
 List of active ConsoleLoggers to send log messages to.


Member Typedef Documentation

typedef SimObject ConsoleLogger::Parent [private]

Reimplemented from SimObject.


Constructor & Destructor Documentation

ConsoleLogger::ConsoleLogger (  ) 

Default constructor, make sure to initalize.

ConsoleLogger::ConsoleLogger ( const char *  fileName,
bool  append = false 
)

Constructor.

Parameters:
fileName File name to log to
append If false, it will clear the file, then start logging, else it will append

ConsoleLogger::~ConsoleLogger (  ) 

Destructor.


Member Function Documentation

void ConsoleLogger::log ( const char *  consoleLine  )  [private]

The log function called by the consumer callback.

Parameters:
consoleLine Line of text to log

bool ConsoleLogger::init (  )  [private]

Utility function, sets up the object (for script interface) returns true if successful.

ConsoleLogger::DECLARE_CONOBJECT ( ConsoleLogger   ) 

static void ConsoleLogger::initPersistFields (  )  [static]

Register dynamic fields in a subclass of ConsoleObject.

See also:
addField(), addFieldV(), addDeprecatedField(), addGroup(), endGroup()

Reimplemented from SimObject.

bool ConsoleLogger::processArguments ( S32  argc,
const char **  argv 
) [virtual]

Console constructor.

      /// // Example script constructor usage.
      /// %obj = new ConsoleLogger( objName, logFileName, [append = false] );
      /// 

Reimplemented from SimObject.

bool ConsoleLogger::attach (  ) 

Attach to the console and begin logging.

Returns true if the action is successful

bool ConsoleLogger::detach (  ) 

Detach from the console and stop logging.

Returns true if the action is successful

void ConsoleLogger::setLogLevel ( ConsoleLogEntry::Level  level  ) 

Sets the level of console messages to log.

Parameters:
level Log level. Only items of the specified level or lower are logged.
See also:
ConsoleLogEntry::Level

ConsoleLogEntry::Level ConsoleLogger::getLogLevel (  )  const

Returns the level of console messages to log.

static void ConsoleLogger::logCallback ( ConsoleLogEntry::Level  level,
const char *  consoleLine 
) [static]

The callback for the console consumer.

Note:
This is a global callback, not executed per-instance.
See also:
Con::addConsumer


Member Data Documentation

True if it is currently consuming and logging.

File stream this object writes to.

This is for use with the default constructor.

If false, it will clear the file before logging to it.

The file name to log to.

List of active ConsoleLoggers to send log messages to.

The level of log messages to log.