|
TrueReality
v0.1.1912
|
Log class which the engine uses for all of its logging needs. More...
#include <Log.h>


Classes | |
| struct | LogTestData |
| A data structure that is used for Unit Tests. More... | |
Public Types | |
| enum | OutputStreamOptions { NO_OUTPUT = 0x00000000, TO_FILE = 0x00000001, TO_CONSOLE = 0x00000002, TO_WRITER = 0x00000004, STANDARD = TO_FILE | TO_CONSOLE | TO_WRITER } |
| Values that represent output stream options. More... | |
| using | LogWriterContainer = std::vector< osg::ref_ptr< LogWriter > > |
| The log writer container. More... | |
Public Member Functions | |
| void | LogMessage (const std::string &cppFile, const std::string &method, int line, const std::string &msg, LogLevel logLevel) const |
| Logs a time-stamped message. More... | |
| void | LogMessage (LogLevel logLevel, const std::string &source, int line, const char *msg,...) const |
| Little more sophisticated method for logging messages. More... | |
| void | LogMessage (LogLevel logLevel, const std::string &source, int line, const std::string &msg) const |
| Little more sophisticated method for logging messages. More... | |
| void | LogMessage (LogLevel logLevel, const std::string &source, int line, const char *msg, va_list list) const |
| Logs a time-stamped message. More... | |
| void | LogMessage (LogLevel logLevel, const std::string &source, const char *msg,...) const |
| Little more sophisticated method for logging messages. More... | |
| void | LogHorizRule () |
| Inserts a horizontal rule into the log file. More... | |
| bool | IsLevelEnabled (LogLevel logLevel) const |
| Queries if a level is enabled. More... | |
| void | SetLogLevel (LogLevel logLevel) |
| Sets the lowest level of logging that will be logged. More... | |
| LogLevel | GetLogLevel () const |
| Gets log level. More... | |
| void | AddWriter (LogWriter &writer) |
| Add an writer that receives all log messages via callback. More... | |
| void | RemoveWriter (LogWriter &writer) |
| Remove an existing LogWriter from the container. More... | |
| const LogWriterContainer & | GetWriters () const |
| Get all registered LogWriters that are registered to receive log messages. More... | |
| LogWriterContainer & | GetWriters () |
| Get all registered LogWriters that are registered to receive log messages. More... | |
| void | SetOutputStreamBit (unsigned int option) |
| Tell the Log where to send output messages. More... | |
| unsigned int | GetOutputStreamBit () const |
| Get the currently defined output stream options. More... | |
| const std::string & | GetName () const |
| Returns the name of this logger. More... | |
| LogManager & | GetLogManagerRef () |
| Returns a reference to the internal Log Manager. More... | |
| void | SetTestMode (bool state) |
| Enables the use of unit test mode which enables capturing of certain data. More... | |
| LogTestData * | GetLastLogData () const |
| Gets the last log data that was in the queue for testing. More... | |
Static Public Member Functions | |
| static const std::string | GetLogLevelString (LogLevel logLevel) |
| Gets log level string. More... | |
| static LogLevel | GetLogLevelForString (const std::string &levelString) |
| Gets log level for string. More... | |
| static Log & | GetInstance (const std::string &name=Log::LOG_DEFAULT_NAME) |
| Retrieve singleton instance of the log class for a give string name. More... | |
| static void | SetDefaultLogLevel (LogLevel newLevel) |
| Sets the default LogLevel for new logs. More... | |
| static void | SetAllLogLevels (LogLevel newLevel) |
| Set the LogLevel for all existing Log instances. More... | |
| static void | SetLogTimeProvider (LogTimeProvider *ltp) |
| This sets a Log time source. More... | |
| static void | SetAllOutputStreamBits (unsigned int option) |
| The same as above, but it sets the bits on ALL active log instances. More... | |
Static Public Attributes | |
| static const std::string | LOG_DEFAULT_NAME |
Protected Member Functions | |
| Log (const std::string &name) | |
| Opens the log file and writes the html header information. More... | |
| ~Log () | |
| Writes any closing html tags and closes the log file. More... | |
Private Attributes | |
| LogImpl * | mImpl |
| bool | mTestingMode = false |
| LogTestData | mLogTestData |
Log class which the engine uses for all of its logging needs.
The log file is formatted using html tags, therefore, any browser should display the log without any problems.
| using trUtil::Logging::Log::LogWriterContainer = std::vector<osg::ref_ptr<LogWriter> > |
|
protected |
Opens the log file and writes the html header information.
All new logs are created with the global default log level.
| name | The name. |
Definition at line 71 of file Log.cpp.
Referenced by GetInstance().

|
protected |
| void trUtil::Logging::Log::AddWriter | ( | LogWriter & | writer | ) |
Add an writer that receives all log messages via callback.
The TO_WRITER OutputStreamOptions bit must be set in order for LogWriters to get triggered.
| [in,out] | writer | The LogWriter to register. |
Definition at line 328 of file Log.cpp.
References mImpl, and trUtil::Logging::LogImpl::mWriters.
|
static |
Retrieve singleton instance of the log class for a give string name.
WARNING: If the log instance does not exist yet, it will be created, but the creation is not thread safe. If you intend to use a log instance in multithreaded code, which I hope you do, make sure to create the instance ahead of time by calling get instance.
| name | (Optional) The logger name. |
Definition at line 203 of file Log.cpp.
References Log(), and trUtil::Logging::LOG_MANAGER().
Referenced by trUtil::Exception::Exception(), trUtil::FileUtils::FileUtils(), trUtil::Exception::LogException(), trUtil::Logging::LogFile::SetFileName(), and trUtil::DefaultSettings::SetupLoggingOptions().


| Log::LogTestData * trUtil::Logging::Log::GetLastLogData | ( | ) | const |
Gets the last log data that was in the queue for testing.
Definition at line 234 of file Log.cpp.
References trUtil::Logging::LOG_MANAGER(), and mLogTestData.

| LogLevel trUtil::Logging::Log::GetLogLevel | ( | ) | const |
Gets log level.
Definition at line 298 of file Log.cpp.
References mImpl, and trUtil::Logging::LogImpl::mLevel.
Referenced by trUtil::Logging::LoggingOff::LoggingOff().

|
static |
Gets log level for string.
| levelString | The level string. |
Definition at line 253 of file Log.cpp.
References trUtil::Logging::LogLevelFromString().

|
static |
Gets log level string.
| logLevel | The log level. |
Definition at line 247 of file Log.cpp.
References trUtil::Logging::LogLevelToString().
Referenced by trUtil::Logging::LogWriterConsole::LogMessage(), and trUtil::Logging::LogWriterFile::LogMessage().


| LogManager & trUtil::Logging::Log::GetLogManagerRef | ( | ) |
Returns a reference to the internal Log Manager.
Definition at line 221 of file Log.cpp.
References trUtil::Logging::LOG_MANAGER().
Referenced by trUtil::Logging::LogFile::SetFileName().


| const std::string & trUtil::Logging::Log::GetName | ( | ) | const |
Returns the name of this logger.
Definition at line 280 of file Log.cpp.
References mImpl, and trUtil::Logging::LogImpl::mName.
| unsigned int trUtil::Logging::Log::GetOutputStreamBit | ( | ) | const |
Get the currently defined output stream options.
Definition at line 274 of file Log.cpp.
References mImpl, and trUtil::Logging::LogImpl::mOutputStreamBit.
| const Log::LogWriterContainer & trUtil::Logging::Log::GetWriters | ( | ) | const |
Get all registered LogWriters that are registered to receive log messages.
Definition at line 334 of file Log.cpp.
References mImpl, and trUtil::Logging::LogImpl::mWriters.
| Log::LogWriterContainer & trUtil::Logging::Log::GetWriters | ( | ) |
Get all registered LogWriters that are registered to receive log messages.
Definition at line 340 of file Log.cpp.
References mImpl, and trUtil::Logging::LogImpl::mWriters.
| bool trUtil::Logging::Log::IsLevelEnabled | ( | LogLevel | logLevel | ) | const |
Queries if a level is enabled.
| logLevel | the type of message to query about. |
Definition at line 286 of file Log.cpp.
References mImpl, and trUtil::Logging::LogImpl::mLevel.
Referenced by trUtil::FileUtils::ChangeDirectoryInternal(), trUtil::FileUtils::DirCopy(), trUtil::FileUtils::DirDelete(), trUtil::FileUtils::FileCopy(), trUtil::FileUtils::FileMove(), trUtil::FileUtils::InternalDirCopy(), trUtil::Exception::LogException(), trUtil::FileUtils::PopDirectory(), trUtil::FileUtils::PushDirectory(), and trUtil::FileUtils::RecursDeleteDir().

| void trUtil::Logging::Log::LogHorizRule | ( | ) |
Inserts a horizontal rule into the log file.
Definition at line 189 of file Log.cpp.
References trUtil::Bits::Has(), trUtil::Logging::LOG_MANAGER(), mImpl, trUtil::Logging::LogImpl::mOutputStreamBit, NO_OUTPUT, and TO_FILE.

| void trUtil::Logging::Log::LogMessage | ( | const std::string & | cppFile, |
| const std::string & | method, | ||
| int | line, | ||
| const std::string & | msg, | ||
| LogLevel | logLevel | ||
| ) | const |
Logs a time-stamped message.
| cppFile | The source file name which generated this message. |
| method | The calling method which generated this message. |
| line | The source code line number. |
| msg | The message to display. |
| logLevel | Level of message being displayed. (error,warning,info, etc) |
Definition at line 85 of file Log.cpp.
References trUtil::Logging::LogWriter::LogData::file, trUtil::Logging::Log::LogTestData::file, trUtil::Logging::LogWriter::LogData::frameNumber, trUtil::Logging::Log::LogTestData::frameNumber, trUtil::Bits::Has(), trUtil::Logging::LogWriter::LogData::line, trUtil::Logging::Log::LogTestData::line, trUtil::Logging::LOG_MANAGER(), trUtil::Logging::LogWriter::LogData::logLevel, trUtil::Logging::Log::LogTestData::logLevel, trUtil::Logging::LogWriter::LogData::logName, trUtil::Logging::Log::LogTestData::logName, trUtil::Logging::LogWriter::LogData::method, trUtil::Logging::Log::LogTestData::method, mImpl, mLogTestData, trUtil::Logging::LogImpl::mName, trUtil::Logging::LogImpl::mOutputStreamBit, trUtil::Logging::LogWriter::LogData::msg, trUtil::Logging::Log::LogTestData::msg, mTestingMode, trUtil::Logging::LogImpl::mWriters, NO_OUTPUT, trUtil::DateTime::SetToLocalTime(), trUtil::Logging::LogWriter::LogData::time, trUtil::Logging::Log::LogTestData::time, TO_CONSOLE, TO_FILE, and TO_WRITER.
Referenced by trUtil::FileUtils::ChangeDirectoryInternal(), trUtil::FileUtils::DirCopy(), trUtil::FileUtils::DirDelete(), trUtil::FileUtils::FileCopy(), trUtil::FileUtils::FileMove(), trUtil::FileUtils::InternalDirCopy(), trUtil::Exception::LogException(), LogMessage(), trUtil::FileUtils::PopDirectory(), trUtil::FileUtils::PushDirectory(), and trUtil::FileUtils::RecursDeleteDir().


| void trUtil::Logging::Log::LogMessage | ( | LogLevel | logLevel, |
| const std::string & | source, | ||
| int | line, | ||
| const char * | msg, | ||
| ... | |||
| ) | const |
Little more sophisticated method for logging messages.
Allows for an unlimited number of parameters in a C-style printf syntax.
| logLevel | - Type of message being displayed. (error,warning,info) |
| source | - String identifier of the source of the message. |
| line | - the line number. |
| msg | - Printf - style format string. |
| ... | Variable arguments providing additional information. |
Definition at line 173 of file Log.cpp.
References LogMessage().

| void trUtil::Logging::Log::LogMessage | ( | LogLevel | logLevel, |
| const std::string & | source, | ||
| int | line, | ||
| const std::string & | msg | ||
| ) | const |
Little more sophisticated method for logging messages.
Allows for an unlimited number of parameters in a C-style printf syntax.
| logLevel | - Type of message being displayed. (error,warning,info) |
| source | - String identifier of the source of the message. |
| line | - the line number. |
| msg | - std::string that has been formatted. |
Definition at line 183 of file Log.cpp.
References LogMessage().

| void trUtil::Logging::Log::LogMessage | ( | LogLevel | logLevel, |
| const std::string & | source, | ||
| int | line, | ||
| const char * | msg, | ||
| va_list | list | ||
| ) | const |
Logs a time-stamped message.
Takes a variable-argument list (va_list) that was created with va_start.
| logLevel | - Type of message being displayed. (error,warning,info) |
| source | - String identifier of the source of the message. |
| line | - line number or negative for unknown. |
| msg | - Printf - style format string. |
| list | - va_list created with va_start. |
Definition at line 153 of file Log.cpp.
References LogMessage().

| void trUtil::Logging::Log::LogMessage | ( | LogLevel | logLevel, |
| const std::string & | source, | ||
| const char * | msg, | ||
| ... | |||
| ) | const |
Little more sophisticated method for logging messages.
Allows for an unlimited number of parameters in a C-style printf syntax.
| logLevel | - Type of message being displayed. (error,warning,info) |
| source | - String identifier of the source of the message. |
| msg | - Printf - style format string. |
| ... | Variable arguments providing additional information. |
Definition at line 163 of file Log.cpp.
References LogMessage().

| void trUtil::Logging::Log::RemoveWriter | ( | LogWriter & | writer | ) |
Remove an existing LogWriter from the container.
| [in,out] | writer | The LogWriter to remove. |
Definition at line 346 of file Log.cpp.
References mImpl, and trUtil::Logging::LogImpl::mWriters.
|
static |
Set the LogLevel for all existing Log instances.
| newLevel | The new level. |
Definition at line 304 of file Log.cpp.
References trUtil::Logging::LOG_MANAGER().
Referenced by trUtil::DefaultSettings::SetupLoggingOptions().


|
static |
The same as above, but it sets the bits on ALL active log instances.
| option | The option. |
Definition at line 265 of file Log.cpp.
References trUtil::Logging::LOG_MANAGER().
Referenced by trUtil::DefaultSettings::SetupLoggingOptions().


|
static |
Sets the default LogLevel for new logs.
| newLevel | The new level. |
Definition at line 241 of file Log.cpp.
References trUtil::Logging::DEFAULT_LOG_LEVEL().

| void trUtil::Logging::Log::SetLogLevel | ( | LogLevel | logLevel | ) |
Sets the lowest level of logging that will be logged.
If the level in set to Debug, all messages will be sent. If the level is set error, only errors will be sent.
| logLevel | the new logging level. |
Definition at line 292 of file Log.cpp.
References mImpl, and trUtil::Logging::LogImpl::mLevel.
Referenced by trUtil::Logging::LoggingOff::LoggingOff(), trUtil::Logging::LogManager::SetAllLogLevels(), and trUtil::Logging::LoggingOff::~LoggingOff().

|
static |
This sets a Log time source.
This allows another part of the system to update and provide both a time and a frame number, as needed. Otherwise, the time will be set on the log data every time log is called.
| [in,out] | ltp | If non-null, the ltp. |
Definition at line 313 of file Log.cpp.
References LOG_E, and trUtil::Logging::LOG_MANAGER().

| void trUtil::Logging::Log::SetOutputStreamBit | ( | unsigned int | option | ) |
Tell the Log where to send output messages.
The supplied parameter is a bitwise combination of OutputStreamOptions. The default is STANDARD, which directs messages to both the console and the output file. For example, to tell the Log to output to the file and console:
| option | A bitwise combination of options. |
| option | The option. |
Definition at line 259 of file Log.cpp.
References mImpl, and trUtil::Logging::LogImpl::mOutputStreamBit.
Referenced by trUtil::Logging::LogManager::SetAllOutputStreamBits().

| void trUtil::Logging::Log::SetTestMode | ( | bool | state | ) |
Enables the use of unit test mode which enables capturing of certain data.
| state | True to state. |
Definition at line 227 of file Log.cpp.
References trUtil::Logging::LOG_MANAGER(), and mTestingMode.

|
static |
|
private |
Definition at line 548 of file Log.h.
Referenced by AddWriter(), GetLogLevel(), GetName(), GetOutputStreamBit(), GetWriters(), IsLevelEnabled(), LogHorizRule(), LogMessage(), RemoveWriter(), SetLogLevel(), SetOutputStreamBit(), and ~Log().
|
mutableprivate |
Definition at line 551 of file Log.h.
Referenced by GetLastLogData(), and LogMessage().
|
private |
Definition at line 550 of file Log.h.
Referenced by LogMessage(), and SetTestMode().