nrEngine::Log Class Reference

Simple class giving you logging functionality for your application. More...


Public Types

enum  {
  LOG_CLIENT = 1 << 0,
  LOG_SERVER = 1 << 1,
  LOG_APP = 1 << 2,
  LOG_KERNEL = 1 << 3,
  LOG_ENGINE = 1 << 4,
  LOG_CONSOLE = 1 << 5,
  LOG_PLUGIN = 1 << 6,
  LOG_ANYTHING = 0xFFFFFFFF
}
 Enumeration containing all available log targets. More...
enum  _LogLevel {
  LL_FATAL_ERROR = 0,
  LL_ERROR,
  LL_WARNING,
  LL_NORMAL,
  LL_DEBUG,
  LL_CHATTY
}
typedef uint32 LogTarget
 Log target is an unsigned integer number.
typedef enum nrEngine::Log::_LogLevel LogLevel

Public Member Functions

Result initialize (const std::string &logPath)
void log (LogTarget target, const char *msg,...)
void log (LogTarget target, LogLevel level, const char *msg,...)
void setEcho (LogTarget from, LogTarget to)
void setLevel (LogLevel logLevel)

Friends

class Engine
 Only engine's core class is allowed to create the instance.


Detailed Description

Simple class giving you logging functionality for your application.

Log Class is using to generate and print logging information on console, MessageBox(WIN32) or in a log file on the disk. You can generate log messages either by giving the message directly or by using message ID-Number of needed. This guarantee to be log messages not hardcoded and they can also be localized (language). All used log messages should be stored in an extra file to allow logging by Msg-Id-Number.

Definition at line 41 of file Log.h.


Member Typedef Documentation

typedef enum nrEngine::Log::_LogLevel nrEngine::Log::LogLevel

Each log message has a certain log level. Each log message that should be logged has such kind of information about the log level.
You can specify which kind of level information should be logged. All messsages with the type above the specified type will be logged. i.e. setting upo the log engine to log messages with LL_WARNING will log fatal errors, errors and warnings.


Member Enumeration Documentation

anonymous enum

Enumeration containing all available log targets.

Enumerator:
LOG_CLIENT  Log the messages to the client log file. Here you should log all messages coming from client.
LOG_SERVER  Log here messages coming from server if you using networking.
LOG_APP  Use this target to log all application logs coming from your game.
LOG_KERNEL  This target will be used by kernel to log it's own messages.
LOG_ENGINE  The engine will use this target to log it own messages. Note: Kernel has got it's own target.
LOG_CONSOLE  This will log to standard console output.
LOG_PLUGIN  Messages coming from plugins should be logged here.
LOG_ANYTHING  Log to all targets above.

Definition at line 48 of file Log.h.

enum nrEngine::Log::_LogLevel

Each log message has a certain log level. Each log message that should be logged has such kind of information about the log level.
You can specify which kind of level information should be logged. All messsages with the type above the specified type will be logged. i.e. setting upo the log engine to log messages with LL_WARNING will log fatal errors, errors and warnings.

Enumerator:
LL_FATAL_ERROR  Messages of this level are produced by fatal errors.
LL_ERROR  This are normal error messages.
LL_WARNING  Only warning, without an error.
LL_NORMAL  Normal logging, some useful information.
LL_DEBUG  Just a little bit more information than normal.
LL_CHATTY  Very verbose message types, say anything anywhere.

Definition at line 84 of file Log.h.


Member Function Documentation

Result nrEngine::Log::initialize ( const std::string &  logPath  ) 

Initialize logging subsystem

Parameters:
logPath - Path to directory where log files will be created
Returns:
either OK or:
  • LOG_ERROR if there was an error by creating the log files

Definition at line 41 of file Log.cpp.

References LL_DEBUG, log(), LOG_ANYTHING, and nrEngine::OK.

Referenced by nrEngine::Engine::initializeLog().

void nrEngine::Log::log ( LogTarget  target,
const char *  msg,
  ... 
)

Log any message to the given log target. You can bitwise combine log targets (i.e. LOG_CONSOLE | LOG_APP) to log to one or more log targets. Each message logged through this method will get a normal log level.

Parameters:
target Target where the log message should be written
msg Formatted message to log

Definition at line 59 of file Log.cpp.

References LL_NORMAL.

Referenced by initialize(), nrEngine::Engine::runEngine(), and nrEngine::Engine::stopEngine().

void nrEngine::Log::log ( LogTarget  target,
LogLevel  level,
const char *  msg,
  ... 
)

Same as the normal log function, but here you can specifiy also the level of logged messages.

Definition at line 90 of file Log.cpp.

void nrEngine::Log::setEcho ( LogTarget  from,
LogTarget  to 
)

This function will setup logging echo. So you can for example specify that all messages given to the engine can be echoing to the console.

Parameters:
from Echo messages from this target
to All messages will be echoed here

Definition at line 137 of file Log.h.

void nrEngine::Log::setLevel ( LogLevel  logLevel  ) 

Setup the default log level. All messages with the level lesser or equal to the specified will be logged.

Parameters:
logLevel Level treshold of logged messages

Definition at line 146 of file Log.h.


The documentation for this class was generated from the following files:
Generated on Wed Sep 12 23:19:43 2007 for nrEngine by  doxygen 1.5.1