Dragonfly  4.3
A text-based game engine
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
df::LogManager Class Reference
Inheritance diagram for df::LogManager:
Inheritance graph
[legend]
Collaboration diagram for df::LogManager:
Collaboration graph
[legend]

Public Member Functions

 ~LogManager ()
 
int startUp ()
 
void shutDown ()
 
int writeLog (const char *fmt,...) const
 
int writeLog (int log_level, const char *fmt,...) const
 
int writeMyLog (std::string filename, const char *fmt,...)
 
int writeMyLog (std::string filename, int log_level, const char *fmt,...)
 
void setLogLevel (int new_log_level)
 
int getLogLevel () const
 
void setFlush (bool do_flush=true)
 
void setLogTimeString (bool log_time_string=true)
 
void setLogStepCount (bool log_step_count=true)
 
- Public Member Functions inherited from df::Manager
std::string getType () const
 
bool isStarted () const
 
int onEvent (const Event *p_event) const
 
int registerInterest (Object *p_o, std::string event_type)
 
int unregisterInterest (Object *p_o, std::string event_type)
 

Static Public Member Functions

static LogManagergetInstance ()
 

Private Member Functions

 LogManager ()
 
 LogManager (LogManager const &)
 
void operator= (LogManager const &)
 

Private Attributes

bool m_do_flush
 
int m_log_level
 
bool m_log_time_string
 
bool m_log_step_count
 
FILE * m_p_f
 
std::map< std::string, FILE * > m_file_list
 

Additional Inherited Members

- Protected Member Functions inherited from df::Manager
void setType (std::string new_type)
 

Constructor & Destructor Documentation

df::LogManager::LogManager ( )
private

Private since a singleton.

df::LogManager::LogManager ( LogManager const &  )
private

Don't allow copy.

df::LogManager::~LogManager ( )

If logfile is open, close it.

Member Function Documentation

static LogManager& df::LogManager::getInstance ( )
static

Get the one and only instance of the LogManager.

int df::LogManager::getLogLevel ( ) const

Get logging level.

void df::LogManager::operator= ( LogManager const &  )
private

Don't allow assignment.

void df::LogManager::setFlush ( bool  do_flush = true)

Set flush of logfile after each write.

void df::LogManager::setLogLevel ( int  new_log_level)

Set logging level.

void df::LogManager::setLogStepCount ( bool  log_step_count = true)

Set prepend step count to log messages.

void df::LogManager::setLogTimeString ( bool  log_time_string = true)

Set prepend time string to log messages.

void df::LogManager::shutDown ( )
virtual

Shut down LogManager (close all logfiles).

Reimplemented from df::Manager.

int df::LogManager::startUp ( )
virtual

Start up LogManager (open main logfile, usually "dragonfly.log").

Reimplemented from df::Manager.

int df::LogManager::writeLog ( const char *  fmt,
  ... 
) const

Write to logfile.

Supports printf() formatting of strings. Return number of bytes written (excluding prepends), -1 if error.

int df::LogManager::writeLog ( int  log_level,
const char *  fmt,
  ... 
) const

Write to logfile.

Only write if indicated log level >= LogManager log level. Supports printf() formatting of strings. Return number of bytes written (excluding prepends), -1 if error.

int df::LogManager::writeMyLog ( std::string  filename,
const char *  fmt,
  ... 
)

Write to custom logfile, identified by filename.

Supports printf() formatting of strings. Return number of bytes written (excluding prepends), -1 if error.

int df::LogManager::writeMyLog ( std::string  filename,
int  log_level,
const char *  fmt,
  ... 
)

Write to custom logfile, identified by filename.

Only write if indicated log level >= LogManager log level. Supports printf() formatting of strings. Return number of bytes written (excluding prepends), -1 if error.

Member Data Documentation

bool df::LogManager::m_do_flush
private

True if flush to disk after write.

std::map<std::string, FILE *> df::LogManager::m_file_list
private

List of custom logfiles.

int df::LogManager::m_log_level
private

Logging level.

bool df::LogManager::m_log_step_count
private

True if prepend step count.

bool df::LogManager::m_log_time_string
private

True if prepend time.

FILE* df::LogManager::m_p_f
private

Pointer to main logfile.