OSB_APP::FileLogBase Class Reference

Inheritance diagram for OSB_APP::FileLogBase:

Inheritance graph
[legend]
Collaboration diagram for OSB_APP::FileLogBase:

Collaboration graph
[legend]
List of all members.

Detailed Description

Logging to a file: base class.

Definition at line 61 of file filelog.h.

Public Member Functions

Client interface:
Application interface:

Private Member Functions

Unlocked operations:
The following functions are called from their public counterparts they apply locking and unlocking as needed.

Private Attributes


Constructor & Destructor Documentation

OSB_APP::FileLogBase::FileLogBase ( int  logLevel  )  [explicit]

Constructor with log level.

virtual OSB_APP::FileLogBase::~FileLogBase (  )  [pure virtual]

Destructor: flushes the temp. buffer and closes the file output stream.

The destructor frist flushes the temporary output buffer and closes the file output stream.
If the temp. buffer is not empty afterwards, its content is written to std::cerr.

Note:
Call clearTemp() to prevent the automatic output of the temp. buffer.

OSB_APP::FileLogBase::FileLogBase ( const FileLogBase  )  [private]

Prevent copying: not implemented.


Member Function Documentation

bool OSB_APP::FileLogBase::append ( const std::string &  name,
const std::string &  dir,
bool  flush = true 
)

Open the output file, append to an existing file.

Parameters:
name Name of the log file.
dir Directory of the log file.
flush Flag to call flush the temporary buffer.
Returns:
os_: true if successful, else false.
Wrapper to openUl() with mode=std::ios::app.

void OSB_APP::FileLogBase::clearTemp (  ) 

Discard the content of the temporary buffer.

void OSB_APP::FileLogBase::clearTempUl (  )  [private]

Discard the content of the temporary buffer.

bool OSB_APP::FileLogBase::close (  ) 

Close the file output stream.

Locks, calls closeUl() and unlocks.

bool OSB_APP::FileLogBase::closeUl (  )  [private]

Close the file output stream.

First flushes the temp. buffer and then closes the os_ if open.

bool OSB_APP::FileLogBase::create ( const std::string &  app,
const std::string &  dir,
bool  flush = true 
)

Create the output file, overwrite an existing file.

Parameters:
app Name of the application.
dir Directory of the log file.
flush Flag to call flush the temporary buffer.
Returns:
os_: true if successful, else false.
Locks, calls createUl() and unlocks.

bool OSB_APP::FileLogBase::createUl ( const std::string &  app,
const std::string &  dir,
bool  flush 
) [private]

Create the output file, overwrite an existing file.

See create() for the description of arguments and return value.

The function first creates the name of the log file and then calls openUl() with mode=std::ios::trunc.

void OSB_APP::FileLogBase::elog (  )  [virtual]

End a log message with a new-line.

Writes std::endl to it-self and unlocks.

Implements OSB_LIB::LogBase.

void OSB_APP::FileLogBase::endlog (  )  [virtual]

End a log message without a new-line.

Unlocks and returns.

Implements OSB_LIB::LogBase.

bool OSB_APP::FileLogBase::flushTemp (  ) 

Write the content ts_ to file output stream.

Returns:
true the temp. buffer was written, else false.
Locks, calls flushTempUl() and unlocks.

bool OSB_APP::FileLogBase::flushTempUl (  )  [private]

Write the content ts_ to file output stream.

See flushTemp() for the description of return value.

If os_ is not open, the function returns immediately false without an effect.

LogBase& OSB_APP::FileLogBase::head ( char   )  [virtual]

Provide header for a new line.

Implements OSB_LIB::LogBase.

LogBase& OSB_APP::FileLogBase::init ( const char *  what  )  [private]

Initialize a log message.

Parameters:
what Header of the message.

virtual void OSB_APP::FileLogBase::lock (  )  const [private, virtual]

Lock the logging interface.

Derived classes that support multi-threaded applications must provide their own implementation of the function.
This default implementation does nothing.

Reimplemented in OSB_APP::FileLockLog.

int OSB_APP::FileLogBase::logLevel (  )  const [virtual]

Get the current log level.

Reimplemented from OSB_LIB::LogBase.

LogBase& OSB_APP::FileLogBase::nl (  )  [virtual]

Begin a new line.

Writes a "\n" and calls head(' ').

Implements OSB_LIB::LogBase.

bool OSB_APP::FileLogBase::open ( const std::string &  name,
const std::string &  dir,
std::ios::openmode  mode,
bool  flush = true 
)

Open the output file.

Parameters:
name Name of the log file.
dir Directory of the log file.
mode Open mode of the log file.
flush Flag to call flush the temporary buffer.
Returns:
os_: true if successful, else false.
Locks, calls openUl() and unlocks.

bool OSB_APP::FileLogBase::openUl ( const std::string &  name,
const std::string &  dir,
std::ios::openmode  mode,
bool  flush 
) [private]

Open the output file.

See open() for the description of arguments and return value.

If the main output stream is already open, the function returns immediately without effect.

FileLogBase& OSB_APP::FileLogBase::operator== ( const FileLogBase  )  [private]

Prevent assignment: not implemented.

std::string OSB_APP::FileLogBase::path (  )  const

Get path and name of log file.

Warning:
Don't use inside a sequence of output operations:
The function locks and unlocks and an output operator is no sequence point!

std::ostream& OSB_APP::FileLogBase::plog (  )  [private, virtual]

Primary log stream.

Returns:
The main output stream os_ if open, else the temp. output stream ts_.

Implements OSB_LIB::LogBase.

void OSB_APP::FileLogBase::setLevel ( int  logLevel  )  [virtual]

Set the log level.

Parameters:
logLevel New log level to be used.

Reimplemented from OSB_LIB::LogBase.

void OSB_APP::FileLogBase::setVerbose ( bool  on  )  [virtual]

Set verbose flag.

Reimplemented from OSB_LIB::LogBase.

std::ostream* OSB_APP::FileLogBase::slog (  )  [private, virtual]

Secondary log stream.

Returns:
std::cout if useCerr_ is false, else std::cerr.

Implements OSB_LIB::LogBase.

LogBase& OSB_APP::FileLogBase::start ( int  level,
bool  noHead 
) [private, virtual]

Start logging a message.

Parameters:
level Log level of the message.
noHead Flag to suppress message header and indentation.
Locks, sets curLevel_ to level and useCerr_ to true if level is less or equal to 2.

Implements OSB_LIB::LogBase.

std::string OSB_APP::FileLogBase::tempBuf (  )  const

Get content of temporary buffer.

std::string OSB_APP::FileLogBase::tempBufUl (  )  const [private]

Get content of temporary buffer.

virtual void OSB_APP::FileLogBase::unlock (  )  const [private, virtual]

Unlock the logging interface.

Derived classes that support multi-threaded applications must provide their own implementation of the function.
This default implementation does nothing.

Reimplemented in OSB_APP::FileLockLog.

bool OSB_APP::FileLogBase::verbose (  )  const [virtual]

Verbose (duplicate) messages on slog()?

Reimplemented from OSB_LIB::LogBase.


Member Data Documentation

std::ofstream OSB_APP::FileLogBase::os_ [private]

The main output stream.

Definition at line 319 of file filelog.h.

std::string OSB_APP::FileLogBase::path_ [private]

Path of the main output stream.

Definition at line 321 of file filelog.h.

std::ostringstream OSB_APP::FileLogBase::ts_ [private]

Temporary output stream.

Definition at line 327 of file filelog.h.

bool OSB_APP::FileLogBase::useCerr_ [private]

Flag to use std::cerr in slog().

Definition at line 324 of file filelog.h.


The documentation for this class was generated from the following file:
Generated on Sat Sep 2 14:17:27 2006 for OSB Library by  doxygen 1.4.7