log_stream.cpp
Go to the documentation of this file.
00001 
00009 /*****************************************************************************
00010 ** Includes
00011 *****************************************************************************/
00012 
00013 #include <utility>
00014 #include "../../include/ecl/streams/log_stream.hpp"
00015 
00016 /*****************************************************************************
00017 ** Namespaces
00018 *****************************************************************************/
00019 
00020 namespace ecl {
00021 
00022 /*****************************************************************************
00023 ** Using
00024 *****************************************************************************/
00025 
00026 using std::string;
00027 
00028 /*****************************************************************************
00029 ** Implementation [LogStream]
00030 *****************************************************************************/
00031 
00032 void LogStream::enableHeader() { write_header = true; }
00033 void LogStream::disableHeader() { write_header = false; }
00034 void LogStream::enableTimeStamp() { write_stamp = true; }
00035 void LogStream::disableTimeStamp() { write_stamp = false; }
00036 
00037 void LogStream::enableMode(int mode, std::string header) { modes.insert( std::make_pair(mode,header) ); }
00038 void LogStream::disableMode(int mode) { modes.erase(mode); }
00039 
00040 bool LogStream::isEnabled() {
00041     if ( modes.size() > 0 ) {
00042         return true;
00043     } else {
00044         return false;
00045     }
00046 }
00047 
00048 bool LogStream::isModeEnabled(int mode) {
00049 
00050     if( modes.count(mode) > 0 ) {
00051         return true;
00052     } else {
00053         return false;
00054     }
00055 }
00056 
00057 LogStream& LogStream::log(int mode) {
00058     if ( write_stamp ) {
00059         (*this) << timestamp.stamp() << " ";
00060     }
00061     if ( write_header ) {
00062         (*this) << "[" << modes[mode] << "] ";
00063     }
00064     if ( write_stamp || write_header ) {
00065         (*this) << ": ";
00066     }
00067     return (*this);
00068 }
00069 
00070 } // namespace ecl
00071 


ecl_streams
Author(s): Daniel Stonier (d.stonier@gmail.com)
autogenerated on Thu Jan 2 2014 11:12:54