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

Last change on this file since 7353 was 6870, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 3.2 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
50 cerr << "Cannot open file " << name << ": " << strerror(errno) << endl;
51 return;
52 }
53
54 MTime time;
55 time.Now();
56
57 *fOut << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">" << endl;
58 *fOut << endl;
59 *fOut << "<html>" << endl;
60 *fOut << "<head>" << endl;
61 *fOut << " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">" << endl;
62 *fOut << " <meta name=\"Author\" content=\"Mars-MLogHtml" << MARSVER << "\">" << endl;
63 *fOut << " <title>MARS - Logging, created " << time << "</title>" << endl;
64 *fOut << "</head>" << endl;
65 *fOut << endl;
66 *fOut << "<pre>" << endl;
67 //*fOut << "<body background=\"background.gif" text="#000000" bgcolor="#000099" link="#1122FF" vlink="#8888FF" alink="#FF0000">
68}
69
70MLogHtml::~MLogHtml()
71{
72 if (!fOut)
73 return;
74
75 *fOut << "</font>" << endl;
76 *fOut << "</pre>" << endl;
77 *fOut << endl;
78 *fOut << "</html>" << endl;
79
80 delete fOut;
81}
82
83void MLogHtml::Underline()
84{
85 if (!fOut)
86 return;
87
88 *fOut << "<u>";
89 fUnderline = kTRUE;
90}
91
92void MLogHtml::SetColor(Int_t col)
93{
94 if (!fOut)
95 return;
96
97 if (fColor>0 && fColor!=col)
98 *fOut << "</font>";
99
100 if (fColor==col)
101 return;
102
103 switch (col)
104 {
105 case 0: break;
106 case 1: *fOut << "<font color=#aa0000>"; break; // err
107 case 2: *fOut << "<font color=#00aaaa>"; break; // warn
108 case 3: *fOut << "<font color=#00aa00>"; break; // inf
109 default: *fOut << "<font color=#0000aa>"; break; // all others (dbg)
110 }
111
112 fColor=col;
113}
114
115void MLogHtml::WriteBuffer(const char *str, int len)
116{
117 if (!fOut)
118 {
119 cout.write(str, len);
120 return;
121 }
122
123 fOut->write(str, len);
124 if (fUnderline)
125 {
126 *fOut << "</u>";
127 fUnderline = kFALSE;
128 }
129}
Note: See TracBrowser for help on using the repository browser.