Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 2782)
+++ trunk/MagicSoft/Mars/Changelog	(revision 2784)
@@ -9,4 +9,6 @@
      - added check of whether input file is a MC file before executing 
        the PreProcess.
+
+
 
  2004/01/13: Wolfgang Wittek
@@ -67,4 +69,14 @@
      - replaced MPedestalCam by MPedPhotCam
      - removed some obsolete includes
+
+   * mbase/BaseLinkDef.h, mbase/Makefile:
+     - added MLogPlugin
+     - added MLogHtml
+
+   * mbase/MLog.[h,cc]:
+     - added use of plugins
+
+   * mbase/MLogPlugin.[h,cc], mbase/MLogHtml.[h,cc]:
+     - added
 
 
Index: trunk/MagicSoft/Mars/mbase/BaseLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/BaseLinkDef.h	(revision 2782)
+++ trunk/MagicSoft/Mars/mbase/BaseLinkDef.h	(revision 2784)
@@ -5,4 +5,5 @@
 #pragma link off all functions;
 
+// Global constants
 #pragma link C++ enum ParticleId_t;
 
@@ -11,12 +12,24 @@
 //#pragma link C++ global kPI;
 
+// Logging
 #pragma link C++ global gLog;
 
 #pragma link C++ class MLog+;
+#pragma link C++ class MLogPlugin+;
+#pragma link C++ class MLogHtml+;
+
+// Basic Network Tools
 #pragma link C++ class MReadSocket+;
 
+// Basic Tools
 #pragma link C++ class MIter+;
 #pragma link C++ class MAstro+;
 #pragma link C++ class MDirIter+;
+
+// Mars core
+#pragma link C++ class MInputStreamID+;
+
+#pragma link C++ class MParContainer+;
+#pragma link C++ class MParList+;
 
 #pragma link C++ class MTask+;
@@ -24,16 +37,12 @@
 #pragma link C++ class MTaskList+;
 
-#pragma link C++ class MParContainer+;
-#pragma link C++ class MParList+;
-
 #pragma link C++ class MFilter+;
 
 #pragma link C++ class MEvtLoop+;
 
+// Mars core (GUI part)
 #pragma link C++ class MStatusDisplay+;
 #pragma link C++ class MProgressBar+;
 #pragma link C++ class MSearch+;
-
-#pragma link C++ class MInputStreamID+;
 
 #pragma link C++ class MGTask+;
@@ -41,8 +50,5 @@
 #pragma link C++ class MGGroupFrame+;
 
-#pragma link C++ class MClone+;
-#pragma link C++ class MPrint+;
-#pragma link C++ class MContinue+;
-
+// Basic containers
 #pragma link C++ class MArray;
 #pragma link C++ class MArrayB;
@@ -55,3 +61,8 @@
 #pragma link C++ class MArgsEntry+;
 
+// Tool tasks
+#pragma link C++ class MClone+;
+#pragma link C++ class MPrint+;
+#pragma link C++ class MContinue+;
+
 #endif
Index: trunk/MagicSoft/Mars/mbase/MLog.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MLog.cc	(revision 2782)
+++ trunk/MagicSoft/Mars/mbase/MLog.cc	(revision 2784)
@@ -100,8 +100,12 @@
 #include <iomanip>
 
+#include <TROOT.h>      // gROOT->GetListOfCleanups()
+
 #ifdef _REENTRANT
 #include <TMutex.h>
 #endif
 #include <TGTextView.h>
+
+#include "MLogPlugin.h"
 
 ClassImp(MLog);
@@ -140,13 +144,17 @@
 void MLog::Init()
 {
-    setp(&fBuffer, &fBuffer+1);
-    *this << '\0';
-
-#ifdef _REENTRANT
+
     //
     // Creat drawing semaphore
     //
+#ifdef _REENTRANT
     fMuxGui = new TMutex;
 #endif
+
+    fPlugins = new TList;
+    gROOT->GetListOfCleanups()->Add(fPlugins);
+
+    setp(&fBuffer, &fBuffer+1);
+    *this << '\0';
 }
 
@@ -202,4 +210,6 @@
 {
     DeallocateFile();
+
+    delete fPlugins;
 #ifdef _REENTRANT
     delete fMuxGui;
@@ -223,4 +233,6 @@
 {
     SetBit(kIsUnderlined);
+
+    fPlugins->ForEach(MLogPlugin, Underline)();
 
     if (TestBit(eNoColors))
@@ -311,4 +323,7 @@
         fOut->write(fBase, len);
 
+    fPlugins->ForEach(MLogPlugin, SetColor)(fOutputLevel);
+    fPlugins->ForEach(MLogPlugin, WriteBuffer)(fBase, len);
+
     if (fDevice&eGui && fGui)
     {
@@ -490,2 +505,15 @@
     flag ? EnableOutputDevice(chk) : DisableOutputDevice(chk);
 }
+
+// --------------------------------------------------------------------------
+//
+// Add a plugin to which the output should be redirected, eg. MLogHtml
+// The user has to take care of its deletion. If the plugin is deleted
+// (and the kMustCleanup bit was not reset accidentaly) the plugin
+// is automatically removed from the list of active plugins.
+//
+void MLog::AddPlugin(MLogPlugin *plug)
+{
+    fPlugins->Add(plug);
+    plug->SetBit(kMustCleanup);
+}
Index: trunk/MagicSoft/Mars/mbase/MLog.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MLog.h	(revision 2782)
+++ trunk/MagicSoft/Mars/mbase/MLog.h	(revision 2784)
@@ -15,4 +15,6 @@
 class TMutex;
 class TGTextView;
+
+class MLogPlugin;
 
 class MLog : public std::streambuf, public std::ostream, public TObject
@@ -71,4 +73,6 @@
 #endif
 
+    TList *fPlugins;
+
     void Init();
 
@@ -192,4 +196,6 @@
     }
 
+    void AddPlugin(MLogPlugin *plug);
+
     ClassDef(MLog, 0) // This is what we call 'The logging system'
 };
Index: trunk/MagicSoft/Mars/mbase/MLogHtml.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MLogHtml.cc	(revision 2784)
+++ trunk/MagicSoft/Mars/mbase/MLogHtml.cc	(revision 2784)
@@ -0,0 +1,124 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// MLogHtml
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MLogHtml.h"
+
+#include <fstream>  // ofstream
+#include <iostream> // 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;
+        return;
+    }
+
+    MTime time;
+    time.Now();
+
+    *fOut << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">" << endl;
+    *fOut << endl;
+    *fOut << "<html>" << endl;
+    *fOut << "<head>" << endl;
+    *fOut << "    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">" << endl;
+    *fOut << "    <meta name=\"Author\" content=\"Mars-MLogHtml" << MARSVER << "\">" << endl;
+    *fOut << "    <title>MARS - Logging, created " << time << "</title>" << endl;
+    *fOut << "</head>" << endl;
+    *fOut << endl;
+    *fOut << "<pre>" << endl;
+    //*fOut << "<body background=\"background.gif" text="#000000" bgcolor="#000099" link="#1122FF" vlink="#8888FF" alink="#FF0000">
+}
+
+MLogHtml::~MLogHtml()
+{
+    if (!fOut)
+        return;
+
+    *fOut << "</font>" << endl;
+    *fOut << "</pre>" << endl;
+    *fOut << endl;
+    *fOut << "</html>" << endl;
+
+    delete fOut;
+}
+
+void MLogHtml::Underline()
+{
+    *fOut << "<u>";
+    fUnderline = kTRUE;
+}
+
+void MLogHtml::SetColor(Int_t col)
+{
+    if (!fOut)
+        return;
+
+    if (fColor>0 && fColor!=col)
+        *fOut << "</font>";
+
+    if (fColor==col)
+        return;
+
+    switch (col)
+    {
+    case 0:  break;
+    case 1:  *fOut << "<font color=#aa0000>"; break;  // err
+    case 2:  *fOut << "<font color=#00aaaa>"; break;  // warn
+    case 3:  *fOut << "<font color=#00aa00>"; break;  // inf
+    default: *fOut << "<font color=#0000aa>"; break;  // all others (dbg)
+    }
+
+    fColor=col;
+}
+
+void MLogHtml::WriteBuffer(const char *str, int len)
+{
+    if (!fOut)
+    {
+        cout.write(str, len);
+        return;
+    }
+
+    fOut->write(str, len);
+    if (fUnderline)
+    {
+        *fOut << "</u>";
+        fUnderline = kFALSE;
+    }
+}
Index: trunk/MagicSoft/Mars/mbase/MLogHtml.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MLogHtml.h	(revision 2784)
+++ trunk/MagicSoft/Mars/mbase/MLogHtml.h	(revision 2784)
@@ -0,0 +1,33 @@
+#ifndef MARS_MLogHtml
+#define MARS_MLogHtml
+
+#ifndef MARS_MLogPlugin
+#include "MLogPlugin.h"
+#endif
+
+class MLogHtml : public MLogPlugin
+{
+private:
+    ofstream *fOut;
+
+    Bool_t fUnderline;
+    Int_t  fColor;
+
+    enum { kFontOpen=BIT(15) };
+
+public:
+    MLogHtml(const char *name);
+    MLogHtml() : fOut(0)
+    {
+    }
+
+    ~MLogHtml();
+
+    void Underline();
+    void SetColor(int col);
+    void WriteBuffer(const char *str, int len);
+
+    ClassDef(MLogHtml, 0) // Logger Plugin for HTML
+};
+
+#endif
Index: trunk/MagicSoft/Mars/mbase/MLogPlugin.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MLogPlugin.cc	(revision 2784)
+++ trunk/MagicSoft/Mars/mbase/MLogPlugin.cc	(revision 2784)
@@ -0,0 +1,35 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// MLogPlugin
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MLogPlugin.h"
+
+ClassImp(MLogPlugin);
+
+using namespace std;
Index: trunk/MagicSoft/Mars/mbase/MLogPlugin.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MLogPlugin.h	(revision 2784)
+++ trunk/MagicSoft/Mars/mbase/MLogPlugin.h	(revision 2784)
@@ -0,0 +1,18 @@
+#ifndef MARS_MLogPlugin
+#define MARS_MLogPlugin
+
+#ifndef ROOT_TObject
+#include <TObject.h>
+#endif
+
+class MLogPlugin : public TObject
+{
+public:
+    virtual void SetColor(int col) { }
+    virtual void Underline() { }
+    virtual void WriteBuffer(const char *str, int len) = 0;
+
+    ClassDef(MLogPlugin, 0) // Base for a logger plugin
+};
+
+#endif
Index: trunk/MagicSoft/Mars/mbase/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mbase/Makefile	(revision 2782)
+++ trunk/MagicSoft/Mars/mbase/Makefile	(revision 2784)
@@ -34,8 +34,11 @@
 
 SRCFILES = MLogo.cc \
-	   MLog.cc \
            MArgs.cc \
            MAstro.cc \
-	   MParContainer.cc \
+	   MLog.cc \
+           MLogManip.cc \
+           MLogPlugin.cc \
+           MLogHtml.cc \
+           MParContainer.cc \
 	   MParList.cc \
 	   MInputStreamID.cc \
@@ -62,6 +65,5 @@
            MClone.cc \
            MContinue.cc \
-           MPrint.cc \
-           MLogManip.cc
+           MPrint.cc
 
 SRCS    = $(SRCFILES)
