35 #include <osg/Referenced> 36 #include <osg/ref_ptr> 37 #include <osg/observer_ptr> 38 #include <osgDB/FileNameUtils> 85 void Log::LogMessage(
const std::string& cppFile,
const std::string& method,
int line,
const std::string& msg, LogLevel logLevel)
const 92 if (logLevel < mImpl->mLevel)
97 OpenThreads::ScopedLock<OpenThreads::Mutex> lock(
LOG_MANAGER->GetMutex());
98 bool hasLogTimeProvider =
LOG_MANAGER->IsLogTimeProviderValid();
101 if (hasLogTimeProvider)
113 logData.
file = osgDB::getSimpleFileName(cppFile);
143 Log::LogWriterContainer::iterator itr =
mImpl->
mWriters.begin();
146 (*itr)->LogMessage(logData);
153 void Log::LogMessage(LogLevel logLevel,
const std::string& source,
int line,
const char* msg, va_list list)
const 157 vsnprintf(buffer, 2049, msg, list);
159 LogMessage(
"", source, line, buffer, logLevel);
163 void Log::LogMessage(LogLevel logLevel,
const std::string& source,
const char* msg, ...)
const 173 void Log::LogMessage(LogLevel logLevel,
const std::string& source,
int line,
const char* msg, ...)
const 178 LogMessage(logLevel, source, line, msg, list);
183 void Log::LogMessage(LogLevel logLevel,
const std::string& source,
int line,
const std::string& msg)
const 229 OpenThreads::ScopedLock<OpenThreads::Mutex> lock(
LOG_MANAGER->GetMutex());
236 OpenThreads::ScopedLock<OpenThreads::Mutex> lock(
LOG_MANAGER->GetMutex());
319 if (ltp != NULL && !
LOG_MANAGER->IsLogTimeProviderValid())
321 LOG_E(
"Unable to assign log time provider because it did not provide a referenced object as a key for deletion");
348 LogWriterContainer::iterator found = std::find(
mImpl->
mWriters.begin(),
LogManager & GetLogManagerRef()
Returns a reference to the internal Log Manager.
Log class which the engine uses for all of its logging needs.
std::string logName
The frame number.
bool Has(N number, B bits)
See if the "bits" are in "number".
std::string file
The name of the Log instance (could be empty)
void LogMessage(const std::string &cppFile, const std::string &method, int line, const std::string &msg, LogLevel logLevel) const
Logs a time-stamped message.
trUtil::Logging::LogLevel logLevel
Interface class get the time for the logger.
int line
The calling method of the message.
void SetToLocalTime()
Changes time to be system local time.
static void SetAllOutputStreamBits(unsigned int option)
The same as above, but it sets the bits on ALL active log instances.
~Log()
Writes any closing html tags and closes the log file.
bool IsLevelEnabled(LogLevel logLevel) const
Queries if a level is enabled.
std::string file
The name of the Log instance (could be empty)
int line
The calling method of the message.
static const std::string GetLogLevelString(LogLevel logLevel)
Gets log level string.
void SetLogLevel(LogLevel logLevel)
Sets the lowest level of logging that will be logged.
LogTestData * GetLastLogData() const
Gets the last log data that was in the queue for testing.
std::string msg
The line number of the source code of the message.
void LogHorizRule()
Inserts a horizontal rule into the log file.
std::vector< osg::ref_ptr< LogWriter > > LogWriterContainer
The log writer container.
LoggingOff(const std::string &name=Log::LOG_DEFAULT_NAME)
Constructor.
unsigned int GetOutputStreamBit() const
Get the currently defined output stream options.
A data structure that is used for Unit Tests.
static LogLevel DEFAULT_LOG_LEVEL(LogLevel::LOG_WARNING)
const LogWriterContainer & GetWriters() const
Get all registered LogWriters that are registered to receive log messages.
void RemoveWriter(LogWriter &writer)
Remove an existing LogWriter from the container.
static void SetDefaultLogLevel(LogLevel newLevel)
Sets the default LogLevel for new logs.
void AddWriter(LogWriter &writer)
Add an writer that receives all log messages via callback.
TR_UTIL_EXPORT LogLevel LogLevelFromString(const std::string &levelString)
Logs level from string.
Interface class to receive messages from the Log.
std::string logName
The frame number.
static void SetAllLogLevels(LogLevel newLevel)
Set the LogLevel for all existing Log instances.
#define LOG_E(msg)
Log an ERROR message.
LogImpl(const std::string &name)
std::string method
The source file of the message.
trUtil::DateTime time
Log level.
static const std::string LOG_DEFAULT_NAME
Namespace that holds various utility classes for the engine.
unsigned int mOutputStreamBit
the current output stream option
const std::string & GetName() const
Returns the name of this logger.
unsigned frameNumber
Time of message.
static LogLevel GetLogLevelForString(const std::string &levelString)
Gets log level for string.
void SetOutputStreamBit(unsigned int option)
Tell the Log where to send output messages.
std::string method
The source file of the message.
Log(const std::string &name)
Opens the log file and writes the html header information.
LogLevel GetLogLevel() const
Gets log level.
void SetTestMode(bool state)
Enables the use of unit test mode which enables capturing of certain data.
Log::LogWriterContainer mWriters
unsigned frameNumber
Time of message.
std::string msg
The line number of the source code of the message.
trUtil::DateTime time
Log level.
trUtil::Logging::LogLevel logLevel
static void SetLogTimeProvider(LogTimeProvider *ltp)
This sets a Log time source.
const TR_UTIL_EXPORT std::string & LogLevelToString(LogLevel logLevel)
Logs level to string.
static Log & GetInstance(const std::string &name=Log::LOG_DEFAULT_NAME)
Retrieve singleton instance of the log class for a give string name.
trUtil::Logging::Log & mLog
static osg::ref_ptr< LogManager > LOG_MANAGER(NULL)