19 #ifndef _LOGSTREAM_HPP_
20 #define _LOGSTREAM_HPP_
28 #include <boost/thread/mutex.hpp>
29 #include <boost/thread/locks.hpp>
30 #include <boost/date_time/posix_time/posix_time.hpp>
31 #include <boost/algorithm/string.hpp>
33 #define DEFAULT_MAX_BUFF_SIZE 5000
55 #pragma GCC visibility push(default)
107 using namespace manip;
140 std::string entityName;
182 const std::string &path,
183 const bool log2console =
false,
190 log2consoleFlag = log2console;
200 maxBufferSize = o.maxBufferSize;
207 if(mBuf.tellp() > 0) {
flush(); }
214 maxBufferSize = o.maxBufferSize;
250 const std::string&
getEntityName ()
const throw() {
if(!lssTemp.getEntityName().empty())
return lssTemp.getEntityName();
else return lssPerm.getEntityName(); }
251 const std::string&
getSource ()
const throw() {
if(!lssTemp.getSource ().empty())
return lssTemp.getSource();
else return lssPerm.getSource(); }
256 LogStream& setMessageType (std::string mt,
const bool permanent =
false);
257 LogStream& setSeverity (std::string ms,
const bool permanent =
false);
271 void put (
const T t) { mBuf << t; }
272 void put (
const std::string &s) { mBuf << s; }
273 void do_write (
bool b =
false);
277 void locked_write(std::string &s);
281 LogStreamSettings lssTemp;
282 std::ostringstream mBuf;
285 static LogStreamSettings lssPerm;
286 static bool log2consoleFlag;
287 static boost::mutex objMutex;
288 static std::string outFilePath;
289 static std::ofstream outFile;
290 static std::deque<std::string> stringPool;
291 static unsigned int maxBufferSize;
301 inline LogStream& operator<< (LogStream& s, ManipResult<T> m) {
return m(s); }
308 template<
typename T>
class ManipResult
372 #pragma GCC visibility pop
LogStream & source(LogStream &s, std::string source)
Definition: logstream.hpp:362
const std::string & getEntityName() const
Definition: logstream.hpp:250
LogStream & high(LogStream &s, const bool permanent=false)
Definition: logstream.hpp:344
LogStream & setLevel(manip_func1 f)
Definition: logstream.hpp:262
A purely informational log.
Definition: logstream.hpp:41
LogStreamSettings & getTempSettings()
Definition: logstream.hpp:253
LogStream & low(LogStream &s, const bool permanent=false)
Definition: logstream.hpp:346
LogStreamSettings & getPermSettings()
Definition: logstream.hpp:252
LogStream & hex()
Definition: logstream.hpp:242
void setOutFilePath(std::string path)
Definition: logstream.hpp:264
log_severity getSeverity() const
Definition: logstream.hpp:249
High.
Definition: logstream.hpp:49
LogStream & base(LogStream &s)
Definition: logstream.hpp:336
log_severity
Used in conjunction with log_type as a log filter.
Definition: logstream.hpp:46
Definition: logstream.hpp:111
LogStream & error_high(LogStream &s, const bool permanent=false)
Definition: logstream.hpp:349
LogStream & info(LogStream &s, const bool permanent=false)
Definition: logstream.hpp:340
LogStream & setSeverity(std::string ms, const bool permanent=false)
Definition: logstream.cpp:44
LogStream & setSeverity(log_severity ms, const bool permanent=false)
Definition: logstream.hpp:259
LogStream & ent(LogStream &s, std::string ent_name)
Definition: logstream.hpp:361
log_type
Used in conjunction with log_serverity as a log filter.
Definition: logstream.hpp:39
LogStream(const std::string &src)
Definition: logstream.hpp:171
~LogStream()
Definition: logstream.hpp:204
LogStream & info_low(LogStream &s, const bool permanent=false)
Definition: logstream.hpp:357
Normal.
Definition: logstream.hpp:48
LogStream & normal(LogStream &s, const bool permanent=false)
Definition: logstream.hpp:345
A log for debugging purposes only.
Definition: logstream.hpp:40
const std::string & getSource() const
Definition: logstream.hpp:251
Low.
Definition: logstream.hpp:47
LogStream & operator<<(LogStream &s, ManipResult< T > m)
Definition: logstream.hpp:301
LogStream & hex(LogStream &s)
Definition: logstream.hpp:332
LogStream & dec()
Definition: logstream.hpp:241
#define DEFAULT_MAX_BUFF_SIZE
Definition: logstream.hpp:33
ManipResult< std::string > src(const std::string &source)
Definition: logstream.hpp:369
const std::string & getSource() const
Definition: logstream.hpp:130
LogStream & endl()
Definition: logstream.hpp:238
LogStream & error_normal(LogStream &s, const bool permanent=false)
Definition: logstream.hpp:350
LogStream & debug_normal(LogStream &s, const bool permanent=false)
Definition: logstream.hpp:353
LogStream & setMessageType(std::string mt, const bool permanent=false)
Definition: logstream.cpp:33
ManipResult(func_type f, T t)
Definition: logstream.hpp:313
ManipResult< std::string > ent(const std::string &ent_name)
Definition: logstream.hpp:366
Definition: logstream.hpp:145
LogStream(const std::string &src, const std::string &path, const bool log2console=false, const unsigned int i=DEFAULT_MAX_BUFF_SIZE)
Definition: logstream.hpp:181
void setLog2consoleFlag(bool b)
Definition: logstream.hpp:265
LogStream & operator=(const LogStream &o)
Definition: logstream.hpp:210
LogStream & info_normal(LogStream &s, const bool permanent=false)
Definition: logstream.hpp:356
Definition: logstream.hpp:57
LogStream & debug(LogStream &s, const bool permanent=false)
Definition: logstream.hpp:341
void setEntityName(const std::string &en)
Definition: logstream.hpp:134
LogStream & operator()(LogStream &s)
Definition: logstream.hpp:317
void setMessageType(log_type mt)
Definition: logstream.hpp:132
const std::string & getEntityName() const
Definition: logstream.hpp:129
LogStream & error(LogStream &s, const bool permanent=false)
Definition: logstream.hpp:339
LogStream & setSource(const std::string &s, const bool permanent=false)
Definition: logstream.hpp:261
LogStream(const LogStream &o)
Definition: logstream.hpp:196
LogStream & flush(LogStream &s)
Definition: logstream.hpp:327
log_severity getSeverity() const
Definition: logstream.hpp:128
void setMaxBufferSize(unsigned int i)
Definition: logstream.hpp:267
log_type getMessageType() const
Definition: logstream.hpp:127
void setSource(const std::string &s)
Definition: logstream.hpp:135
LogStreamSettings & operator=(const LogStreamSettings &lss)
Definition: logstream.hpp:116
LogStream & base()
Definition: logstream.hpp:245
LogStream & debug_low(LogStream &s, const bool permanent=false)
Definition: logstream.hpp:354
LogStream & dec(LogStream &s)
Definition: logstream.hpp:331
LogStreamSettings()
Definition: logstream.hpp:114
LogStream & setEntityName(const std::string &en, const bool permanent=false)
Definition: logstream.hpp:260
void setSeverity(log_severity ms)
Definition: logstream.hpp:133
log_type getMessageType() const
Definition: logstream.hpp:248
An error log.
Definition: logstream.hpp:42
LogStream & oct()
Definition: logstream.hpp:243
LogStream & setMessageType(log_type mt, const bool permanent=false)
Definition: logstream.hpp:258
LogStream & endl(LogStream &s)
Definition: logstream.hpp:328
LogStream & oct(LogStream &s)
Definition: logstream.hpp:333
LogStream(manip_func1 manip=info_normal)
Definition: logstream.hpp:154
LogStream & debug_high(LogStream &s, const bool permanent=false)
Definition: logstream.hpp:352
LogStream & flush()
Definition: logstream.hpp:237
LogStream & info_high(LogStream &s, const bool permanent=false)
Definition: logstream.hpp:355
LogStream & error_low(LogStream &s, const bool permanent=false)
Definition: logstream.hpp:351
LogStream(manip_func1 manip, const std::string &src)
Definition: logstream.hpp:162