GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GwLogCollector.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2004 by Olivier Stezowski *
3  * stezow(AT)ipnl.in2p3.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
26 #ifndef Gw_LogCollector
27 #define Gw_LogCollector
28 #define Gw_LOGCOLLECTOR_H Gw_LogCollector
29 
30 #include <iostream>
31 #include <sstream>
32 #include <vector>
33 
34 namespace Gw {
35 
36 class LogMessage;
37 
39 
43 {
44 private:
46  std::string fName;
47 
48 protected:
50  unsigned short fMinLevel;
51  unsigned short fMaxLevel;
52 
53 private:
55  bool fIsDeleteByCentralLog;
56 
57 public:
59  LogCollector(const char *, bool isdelbycental = false);
61  virtual ~LogCollector();
62 
64  static LogCollector *theCollector();
65 
67  void SetLevelFiltering(unsigned short min, unsigned short max)
68  { fMinLevel = min; fMaxLevel= max; }
69 
71 
75  virtual void DoCollect(LogMessage &)
76  {;}
77 
78  virtual std::string &GetName()
79  {return fName;}
80 
82  virtual bool IsDeleteByCentralLog() const
83  { return fIsDeleteByCentralLog; }
84 };
85 
87 
91 {
92 private:
93  std::ostream *fOutputStream;
94 
95 public:
96  OStreamCollector(const char *, bool isdelbycental = false);
97  virtual ~OStreamCollector();
98 
100  virtual void DoCollect(LogMessage &);
101 };
102 
103 } // namespace
104 
105 #endif
106 
107 
108 
109 
110 
void SetLevelFiltering(unsigned short min, unsigned short max)
LogMessages processed by the LogCollector if their level is between min and max.
Base class for a Log collector.
unsigned short fMaxLevel
virtual void DoCollect(LogMessage &)
write the message in a file
Base class for a Log message.
Definition: GwLogMessage.h:94
virtual std::string & GetName()
OStreamCollector(const char *, bool isdelbycental=false)
unsigned short fMinLevel
to send to the log server only message having their level between min and max
Base class for a Log collector.
LogCollector(const char *, bool isdelbycental=false)
virtual ~LogCollector()
static LogCollector * theCollector()
return the current logcollector
virtual void DoCollect(LogMessage &)
Default, collect nothing !
virtual bool IsDeleteByCentralLog() const
if true, the collector is deleted by the central log