00001 #include "stdafx.h"
00002 #include "LogStream.h"
00003 #include "BON.h"
00004 #include "BONImpl.h"
00005
00006 #include "globals.h"
00007 extern Globals global_vars;
00008
00009 LogStream::LogStream()
00010 : m_proj( BON::Project())
00011 , m_msgtype( MSG_NORMAL)
00012 , m_buff()
00013 { }
00014
00015 LogStream::~LogStream()
00016 {
00017 m_proj = BON::Project();
00018 m_buff = "";
00019 }
00020
00021 void LogStream::flushit()
00022 {
00023 *this << "\n";
00024 }
00025
00026
00027
00028
00029 LogStream& operator<<( LogStream& stream, msgtype_enum msgtype)
00030 {
00031 if( !stream.m_buff.empty()) stream << "\n";
00032
00033 stream.m_msgtype = msgtype;
00034
00035
00036
00037
00038
00039
00040
00041 return stream;
00042
00043 }
00044
00045 LogStream& operator<<( LogStream& stream, const BON::FCO& fco)
00046 {
00047 std::string tok = "<b>Null_object</b>";
00048 if( fco)
00049 {
00050 try {
00051 std::string id, nm;
00052 id = fco->getID();
00053 nm = fco->getName();
00054 tok = "<A HREF=\"mga:" + id +"\">" + nm + "</A>";
00055 } catch( ...) {
00056 }
00057 }
00058
00059 return stream << tok;
00060 }
00061
00062 LogStream& operator<<( LogStream& stream, const char * r)
00063 {
00064 return stream << std::string( r);
00065 }
00066
00067 LogStream& operator<<( LogStream& stream, const std::string& r)
00068 {
00069 stream.write( r.c_str(), r.length());
00070
00071 stream.m_buff += r;
00072 if( r.find('\n') != std::string::npos)
00073 {
00074 if( !global_vars.silent_mode) {
00075 try { stream.m_proj->consoleMsg( stream.m_buff, stream.m_msgtype); }
00076 catch( ... ) { }
00077 }
00078 stream.m_buff = "";
00079 }
00080
00081 return stream;
00082 }
00083
00084
00085 LogStream& operator<<( LogStream& stream, const int i)
00086 {
00087 char t[32];
00088 sprintf( t, "%i", i);
00089 return stream << std::string( t);
00090 }
00091