source: trunk/MagicSoft/Mars/mbase/MLogHtml.cc@ 2903

Last change on this file since 2903 was 2784, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 3.1 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of MARS, the MAGIC Analysis and Reconstruction
5! * Software. It is distributed to you in the hope that it can be a useful
6! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
7! * It is distributed WITHOUT ANY WARRANTY.
8! *
9! * Permission to use, copy, modify and distribute this software and its
10! * documentation for any purpose is hereby granted without fee,
11! * provided that the above copyright notice appear in all copies and
12! * that both that copyright notice and this permission notice appear
13! * in supporting documentation. It is provided "as is" without express
14! * or implied warranty.
15! *
16!
17!
18! Author(s): Thomas Bretz, 1/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2004
21!
22!
23\* ======================================================================== */
24
25
26//////////////////////////////////////////////////////////////////////////////
27//
28// MLogHtml
29//
30//////////////////////////////////////////////////////////////////////////////
31#include "MLogHtml.h"
32
33#include <fstream> // ofstream
34#include <iostream> // cout
35
36#include "MTime.h"
37
38ClassImp(MLogHtml);
39
40using namespace std;
41
42MLogHtml::MLogHtml(const char *name) : fUnderline(0), fColor(-1)
43{
44 fOut = new ofstream(name);
45 if (!*fOut)
46 {
47 delete fOut;
48 fOut = NULL;
49 return;
50 }
51
52 MTime time;
53 time.Now();
54
55 *fOut << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">" << endl;
56 *fOut << endl;
57 *fOut << "<html>" << endl;
58 *fOut << "<head>" << endl;
59 *fOut << " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">" << endl;
60 *fOut << " <meta name=\"Author\" content=\"Mars-MLogHtml" << MARSVER << "\">" << endl;
61 *fOut << " <title>MARS - Logging, created " << time << "</title>" << endl;
62 *fOut << "</head>" << endl;
63 *fOut << endl;
64 *fOut << "<pre>" << endl;
65 //*fOut << "<body background=\"background.gif" text="#000000" bgcolor="#000099" link="#1122FF" vlink="#8888FF" alink="#FF0000">
66}
67
68MLogHtml::~MLogHtml()
69{
70 if (!fOut)
71 return;
72
73 *fOut << "</font>" << endl;
74 *fOut << "</pre>" << endl;
75 *fOut << endl;
76 *fOut << "</html>" << endl;
77
78 delete fOut;
79}
80
81void MLogHtml::Underline()
82{
83 *fOut << "<u>";
84 fUnderline = kTRUE;
85}
86
87void MLogHtml::SetColor(Int_t col)
88{
89 if (!fOut)
90 return;
91
92 if (fColor>0 && fColor!=col)
93 *fOut << "</font>";
94
95 if (fColor==col)
96 return;
97
98 switch (col)
99 {
100 case 0: break;
101 case 1: *fOut << "<font color=#aa0000>"; break; // err
102 case 2: *fOut << "<font color=#00aaaa>"; break; // warn
103 case 3: *fOut << "<font color=#00aa00>"; break; // inf
104 default: *fOut << "<font color=#0000aa>"; break; // all others (dbg)
105 }
106
107 fColor=col;
108}
109
110void MLogHtml::WriteBuffer(const char *str, int len)
111{
112 if (!fOut)
113 {
114 cout.write(str, len);
115 return;
116 }
117
118 fOut->write(str, len);
119 if (fUnderline)
120 {
121 *fOut << "</u>";
122 fUnderline = kFALSE;
123 }
124}
Note: See TracBrowser for help on using the repository browser.