TrueReality  v0.1.1912
trUtil::Logging::LogManager Class Reference

Manager for logs. More...

#include <LogManager.h>

Inheritance diagram for trUtil::Logging::LogManager:
Collaboration diagram for trUtil::Logging::LogManager:

Public Member Functions

 LogManager ()
 Default constructor. More...
 
 ~LogManager ()
 Destructor. More...
 
bool AddInstance (const std::string &name, Log *log)
 Stores a new Log instance in the manager. More...
 
LogGetInstance (const std::string &name)
 Retrieves a stored Log instance. More...
 
void SetAllLogLevels (const LogLevel &newLevel)
 Set the Log Level for all active Loggers. More...
 
void SetAllOutputStreamBits (unsigned int option)
 Set the OutputStreamOptions bits for all stored Loggers The bits correspond to: NO_OUTPUT = 0x00000000, /// Log messages don't get written to any device TO_FILE = 0x00000001, /// Log messages get sent to the output file TO_CONSOLE = 0x00000002,/// Log messages get sent to the console TO_WRITER = 0x00000004,/// Log messages get sent to all registered writers STANDARD = TO_FILE | TO_CONSOLE | TO_WRITER /// The default setting. More...
 
bool IsLogTimeProviderValid () const
 Check if the Log Time Provider is currently valid in this manager. More...
 
void ReOpenFile ()
 Reopens the log file. More...
 
void LogHorizRule ()
 Writes out a horizontal line to the Log File. More...
 
void LogMessageToFile (const LogWriter::LogData &logData)
 Write out a message to the Log file. More...
 
void LogMessageToConsole (const LogWriter::LogData &logData)
 Write out a message to the screen console. More...
 
void SetLogTimeProvider (LogTimeProvider *ltp)
 This sets a Log time source. More...
 
unsigned int GetFrameNumber ()
 Returns the stored frame number. More...
 
const trUtil::DateTimeGetDateTime ()
 Returns the reference to the stored DateTime object. More...
 
OpenThreads::Mutex & GetMutex ()
 Returns the reference to an internal OpenThreads Mutex. More...
 

Private Attributes

trUtil::HashMap< std::string, osg::ref_ptr< Log > > mInstances
 
osg::ref_ptr< LogWritermLogWriterConsole
 
osg::ref_ptr< LogWriterFilemLogWriterFile
 writes to console More...
 
osg::observer_ptr< osg::Referenced > mLogTimeProviderAsRef
 writes to file More...
 
LogTimeProvidermLogTimeProvider
 
OpenThreads::Mutex mMutex
 

Detailed Description

Manager for logs.

Definition at line 56 of file LogManager.h.

Constructor & Destructor Documentation

◆ LogManager()

trUtil::Logging::LogManager::LogManager ( )

Default constructor.

Definition at line 35 of file LogManager.cpp.

◆ ~LogManager()

trUtil::Logging::LogManager::~LogManager ( )

Destructor.

Definition at line 43 of file LogManager.cpp.

References mInstances, mLogWriterConsole, and mLogWriterFile.

Member Function Documentation

◆ AddInstance()

bool trUtil::Logging::LogManager::AddInstance ( const std::string &  name,
Log log 
)

Stores a new Log instance in the manager.

Parameters
nameThe name.
[in,out]logIf non-null, the log.
Returns
True if it succeeds, false if it fails.

Definition at line 51 of file LogManager.cpp.

References mInstances.

◆ GetDateTime()

const trUtil::DateTime & trUtil::Logging::LogManager::GetDateTime ( )

Returns the reference to the stored DateTime object.

Returns
The date time.

Definition at line 139 of file LogManager.cpp.

References trUtil::Logging::LogTimeProvider::GetDateTime(), and mLogTimeProvider.

Here is the call graph for this function:

◆ GetFrameNumber()

unsigned int trUtil::Logging::LogManager::GetFrameNumber ( void  )

Returns the stored frame number.

Returns
The frame number.

Definition at line 133 of file LogManager.cpp.

References trUtil::Logging::LogTimeProvider::GetFrameNumber(), and mLogTimeProvider.

Here is the call graph for this function:

◆ GetInstance()

Log * trUtil::Logging::LogManager::GetInstance ( const std::string &  name)

Retrieves a stored Log instance.

Parameters
name- name of the Log to retrieve.
Returns
Null if it fails, else the instance.

Definition at line 57 of file LogManager.cpp.

References mInstances.

◆ GetMutex()

OpenThreads::Mutex & trUtil::Logging::LogManager::GetMutex ( )

Returns the reference to an internal OpenThreads Mutex.

Returns
The mutex.

Definition at line 145 of file LogManager.cpp.

References mMutex.

◆ IsLogTimeProviderValid()

bool trUtil::Logging::LogManager::IsLogTimeProviderValid ( ) const

Check if the Log Time Provider is currently valid in this manager.

Returns
True if the log time provider is valid, false if not.

Definition at line 88 of file LogManager.cpp.

References mLogTimeProvider, and mLogTimeProviderAsRef.

◆ LogHorizRule()

void trUtil::Logging::LogManager::LogHorizRule ( )

Writes out a horizontal line to the Log File.

Definition at line 101 of file LogManager.cpp.

References mLogWriterFile.

◆ LogMessageToConsole()

void trUtil::Logging::LogManager::LogMessageToConsole ( const LogWriter::LogData logData)

Write out a message to the screen console.

Parameters
logDataInformation describing the log.

Definition at line 113 of file LogManager.cpp.

References mLogWriterConsole.

◆ LogMessageToFile()

void trUtil::Logging::LogManager::LogMessageToFile ( const LogWriter::LogData logData)

Write out a message to the Log file.

Parameters
logDataInformation describing the log.

Definition at line 107 of file LogManager.cpp.

References mLogWriterFile.

◆ ReOpenFile()

void trUtil::Logging::LogManager::ReOpenFile ( )

Reopens the log file.

This is used if a file failed to open, or file name has changed.

Definition at line 94 of file LogManager.cpp.

References mLogWriterFile.

Referenced by trUtil::Logging::LogFile::SetFileName().

Here is the caller graph for this function:

◆ SetAllLogLevels()

void trUtil::Logging::LogManager::SetAllLogLevels ( const LogLevel &  newLevel)

Set the Log Level for all active Loggers.

Parameters
newLevelThe new level.

Definition at line 68 of file LogManager.cpp.

References mInstances, and trUtil::Logging::Log::SetLogLevel().

Here is the call graph for this function:

◆ SetAllOutputStreamBits()

void trUtil::Logging::LogManager::SetAllOutputStreamBits ( unsigned int  option)

Set the OutputStreamOptions bits for all stored Loggers The bits correspond to: NO_OUTPUT = 0x00000000, /// Log messages don't get written to any device TO_FILE = 0x00000001, /// Log messages get sent to the output file TO_CONSOLE = 0x00000002,/// Log messages get sent to the console TO_WRITER = 0x00000004,/// Log messages get sent to all registered writers STANDARD = TO_FILE | TO_CONSOLE | TO_WRITER /// The default setting.

Parameters
optionThe option.

Definition at line 78 of file LogManager.cpp.

References mInstances, and trUtil::Logging::Log::SetOutputStreamBit().

Here is the call graph for this function:

◆ SetLogTimeProvider()

void trUtil::Logging::LogManager::SetLogTimeProvider ( LogTimeProvider ltp)

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.

Parameters
[in,out]ltpIf non-null, the ltp.

Definition at line 119 of file LogManager.cpp.

References trUtil::Logging::LogTimeProvider::AsReferenced(), mLogTimeProvider, and mLogTimeProviderAsRef.

Here is the call graph for this function:

Member Data Documentation

◆ mInstances

trUtil::HashMap<std::string, osg::ref_ptr<Log> > trUtil::Logging::LogManager::mInstances
private

◆ mLogTimeProvider

LogTimeProvider* trUtil::Logging::LogManager::mLogTimeProvider
private

◆ mLogTimeProviderAsRef

osg::observer_ptr<osg::Referenced> trUtil::Logging::LogManager::mLogTimeProviderAsRef
private

writes to file

Definition at line 204 of file LogManager.h.

Referenced by IsLogTimeProviderValid(), and SetLogTimeProvider().

◆ mLogWriterConsole

osg::ref_ptr<LogWriter> trUtil::Logging::LogManager::mLogWriterConsole
private

Definition at line 202 of file LogManager.h.

Referenced by LogMessageToConsole(), and ~LogManager().

◆ mLogWriterFile

osg::ref_ptr<LogWriterFile> trUtil::Logging::LogManager::mLogWriterFile
private

writes to console

Definition at line 203 of file LogManager.h.

Referenced by LogHorizRule(), LogMessageToFile(), ReOpenFile(), and ~LogManager().

◆ mMutex

OpenThreads::Mutex trUtil::Logging::LogManager::mMutex
private

Definition at line 206 of file LogManager.h.

Referenced by GetMutex().


The documentation for this class was generated from the following files: