library of assembled shared sources |
http://lass.cocamware.com |
#include <logger.h>
Public Types | |
enum | LogMode { lmAppend, lmClear } |
typedef ProxyOStream::TMask | TMask |
Public Member Functions | |
Logger (const std::string &iLogFile, LogMode iLogMode=lmClear) | |
Default constructor for the sake of static library. | |
~Logger () | |
Unsubscribe to all proxys. | |
void | subscribeTo (ProxyOStream *iProxy, TMask iFilter=ProxyOStream::acceptAll) |
Subscribe this logger to a proxy stream and set the filter on it. | |
void | unsubscribeTo (ProxyOStream *iProxy) |
Unsubscribe this logger to a proxy stream. | |
TMask | filter (ProxyOStream *iProxy) |
return the filter between proxy and logger | |
void | setFilter (ProxyOStream *iProxy, TMask iFilter) |
Set filter between proxy and logger. | |
Private Types | |
typedef std::list< ProxyOStream * > | TProxyList |
Private Member Functions | |
void | openLog (const std::string &iLogFile, LogMode iLogMode=lmClear) |
open file to write logs to. | |
Private Attributes | |
std::ofstream | logFile_ |
TProxyList | proxyList_ |
Logger logger("logfile.txt"); // construct logger\n logger.subscribe(proxyOut()); // subsribe to the proxy out stream.\n ...\n logger.unsubscribe(proxyOut());\n
Definition at line 80 of file logger.h.
typedef std::list<ProxyOStream*> lass::io::Logger::TProxyList [private] |
lass::io::Logger::Logger | ( | const std::string & | iLogFilename, | |
LogMode | iLogMode = lmClear | |||
) |
Default constructor for the sake of static library.
We don't recommend of using it. Create a logger to a log file and specify if it must append to the file or clear it.
Definition at line 62 of file logger.cpp.
References openLog().
lass::io::Logger::~Logger | ( | ) |
Unsubscribe to all proxys.
Definition at line 71 of file logger.cpp.
References logFile_, proxyList_, and lass::io::ProxyOStream::remove().
void lass::io::Logger::subscribeTo | ( | ProxyOStream * | iProxy, | |
TMask | iFilter = ProxyOStream::acceptAll | |||
) |
Subscribe this logger to a proxy stream and set the filter on it.
iProxy | if null pointer, then an exception is thrown. | |
iFilter | filter between proxy and logger |
Definition at line 86 of file logger.cpp.
References lass::io::ProxyOStream::add(), LASS_ENFORCE_POINTER, logFile_, and proxyList_.
void lass::io::Logger::unsubscribeTo | ( | ProxyOStream * | iProxy | ) |
Unsubscribe this logger to a proxy stream.
iProxy | if null pointer, then an exception is thrown. |
Definition at line 97 of file logger.cpp.
References LASS_ENFORCE_POINTER, logFile_, proxyList_, and lass::io::ProxyOStream::remove().
Logger::TMask lass::io::Logger::filter | ( | ProxyOStream * | iProxy | ) |
return the filter between proxy and logger
iProxy | logger must be subscribed to this proxy (and proxy should not be a NULL pointer), otherwise and exception is thrown. |
Definition at line 109 of file logger.cpp.
References LASS_ENFORCE_POINTER, and logFile_.
void lass::io::Logger::setFilter | ( | ProxyOStream * | iProxy, | |
TMask | iFilter | |||
) |
Set filter between proxy and logger.
iProxy | logger must be subscribed to this proxy (and proxy should not be a NULL pointer), otherwise and exception is thrown. | |
iFilter | the filter between proxy and logger. |
Definition at line 121 of file logger.cpp.
References LASS_ENFORCE_POINTER, and logFile_.
void lass::io::Logger::openLog | ( | const std::string & | iLogFilename, | |
LogMode | iLogMode = lmClear | |||
) | [private] |
open file to write logs to.
You should do this in (and only in) the constructor. The Logger doesn't like to have no filestreams open, or to change the file stream since it relies on it to subscribe to the different proxy streams. So make sure that you have a file stream op after construction, and that you never change it!
QUESTION: is this true? afterall, if you open a different file, the pointer to lofFile_ will not change, but maybe the proxy streams don't like closed filestreams?
Definition at line 137 of file logger.cpp.
References LASS_THROW, lmAppend, logFile_, and lass::prim::out().
Referenced by Logger().
std::ofstream lass::io::Logger::logFile_ [private] |
Definition at line 108 of file logger.h.
Referenced by filter(), openLog(), setFilter(), subscribeTo(), unsubscribeTo(), and ~Logger().
TProxyList lass::io::Logger::proxyList_ [private] |
Definition at line 109 of file logger.h.
Referenced by subscribeTo(), unsubscribeTo(), and ~Logger().
Generated on Mon Nov 10 14:22:09 2008 for Library of Assembled Shared Sources by 1.5.7.1 |