/* ======================================================================== *\ ! ! * ! * This file is part of MARS, the MAGIC Analysis and Reconstruction ! * Software. It is distributed to you in the hope that it can be a useful ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes. ! * It is distributed WITHOUT ANY WARRANTY. ! * ! * Permission to use, copy, modify and distribute this software and its ! * documentation for any purpose is hereby granted without fee, ! * provided that the above copyright notice appear in all copies and ! * that both that copyright notice and this permission notice appear ! * in supporting documentation. It is provided "as is" without express ! * or implied warranty. ! * ! ! ! Author(s): Thomas Bretz, 1/2004 ! ! Copyright: MAGIC Software Development, 2000-2004 ! ! \* ======================================================================== */ ////////////////////////////////////////////////////////////////////////////// // // MLogHtml // ////////////////////////////////////////////////////////////////////////////// #include "MLogHtml.h" #include // necessary for Fedora core 2 with kernel 2.6.9-1.667 #1 and gcc 3.4.2 #include // necessary for Fedora core 2 with kernel 2.6.9-1.667 #1 and gcc 3.4.2 #include // ofstream #include // cout #include "MTime.h" ClassImp(MLogHtml); using namespace std; MLogHtml::MLogHtml(const char *name) : fUnderline(0), fColor(-1) { fOut = new ofstream(name); if (!*fOut) { delete fOut; fOut = NULL; cerr << "Cannot open file " << name << ": " << strerror(errno) << endl; return; } // switch off buffering fOut->rdbuf()->pubsetbuf(0,0); MTime time; time.Now(); *fOut << "" << endl; *fOut << endl; *fOut << "" << endl; *fOut << "" << endl; *fOut << " " << endl; *fOut << " " << endl; *fOut << " MARS - Logging, created " << time << "" << endl; *fOut << "" << endl; *fOut << endl; *fOut << "
" << endl;
    //*fOut << "
}

MLogHtml::~MLogHtml()
{
    if (!fOut)
        return;

    *fOut << "" << endl;
    *fOut << "
" << endl; *fOut << endl; *fOut << "" << endl; delete fOut; } void MLogHtml::Underline() { if (!fOut) return; *fOut << ""; fUnderline = kTRUE; } void MLogHtml::SetColor(Int_t col) { if (!fOut) return; if (fColor>0 && fColor!=col) *fOut << ""; if (fColor==col) return; switch (col) { case 0: break; case 1: *fOut << ""; break; // err case 2: *fOut << ""; break; // warn (olive?) case 3: // inf case 4: // inf2 case 5: *fOut << ""; break; // inf3 default: *fOut << ""; break; // all others (dbg) } fColor=col; } void MLogHtml::WriteBuffer(const char *str, int len) { if (!fOut) { cout.write(str, len); return; } TString txt(str, len); txt.ReplaceAll(">", ">"); txt.ReplaceAll("<", "<"); fOut->write(txt.Data(), txt.Length()); if (fUnderline) { *fOut << ""; fUnderline = kFALSE; } }