casacore
Loading...
Searching...
No Matches
LogSinkInterface.h
Go to the documentation of this file.
1//# LogSinkInterface.h: Accepts LogMessages and posts them to some destination
2//# Copyright (C) 1996,2000,2001,2003
3//# Associated Universities, Inc. Washington DC, USA.
4//#
5//# This library is free software; you can redistribute it and/or modify it
6//# under the terms of the GNU Library General Public License as published by
7//# the Free Software Foundation; either version 2 of the License, or (at your
8//# option) any later version.
9//#
10//# This library is distributed in the hope that it will be useful, but WITHOUT
11//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13//# License for more details.
14//#
15//# You should have received a copy of the GNU Library General Public License
16//# along with this library; if not, write to the Free Software Foundation,
17//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18//#
19//# Correspondence concerning AIPS++ should be addressed as follows:
20//# Internet email: casa-feedback@nrao.edu.
21//# Postal address: AIPS++ Project Office
22//# National Radio Astronomy Observatory
23//# 520 Edgemont Road
24//# Charlottesville, VA 22903-2475 USA
25
26#ifndef CASA_LOGSINKINTERFACE_H
27#define CASA_LOGSINKINTERFACE_H
28
29//# Includes
30#include <casacore/casa/aips.h>
31#include <casacore/casa/Logging/LogFilterInterface.h>
32
33
34namespace casacore { //# NAMESPACE CASACORE - BEGIN
35
36// <summary>
37//Accepts LogMessages and posts them to some destination
38// </summary>
39
40// <use visibility=local>
41
42// <reviewed reviewer="wbrouw" date="1996/08/21" tests="tLogging.cc" demos="dLogging.cc">
43// </reviewed>
44
45// <prerequisite>
46// <li> <linkto class=LogMessage>LogMessage</linkto>
47// <li> <linkto class=LogFilterInterface>LogFilterInterface</linkto>
48// </prerequisite>
49//
50// <etymology>
51// Log as in "Log Book." Sink from its common usage ("source/sink") as a thing
52// which can accept some substance or energy. Interface because this is an
53// abstract, not concrete, class.
54// </etymology>
55//
56// <synopsis>
57// This abstract base class is not intended for applications programmers.
58// Instead they should look at <linkto class=LogSink>LogSink</linkto>.
59//
60// This class defines a minimal "posting" interface for all objects which accept
61// log messages. The fundamental model of a <src>LogSinkInterface</src> is:
62// <ol>
63// <li> That it contains a
64// <linkto class=LogFilterInterface>LogFilterInterface</linkto> that is
65// used to accept or reject messages; and
66// <li> That it has a post message that takes a log message; and, if it passes
67// the filter, does something with it (prints it to a stream, saves it to
68// a table, ...).
69// </ol>
70// There is no notion of local vs global sinks - that is imposed by
71// <src>LogSink</src>.
72// </synopsis>
73//
74// <example>
75// <srcblock>
76// LogSinkInterface &ref = ...;
77// LogMessage message(...);
78// ref.postLocally(message);
79// if (ref.filter().lowestPriority() != LogMessage::DEBUGGING) {
80// ref.filter(LogMessage::DEBUGGING);
81// }
82// </srcblock>
83// For a more complete example see <linkto file="Logging.h">Logging.h</linkto>.
84// </example>
85//
86// <motivation>
87// Make it straightforward to extend the number of places a message may be
88// in the future through derivation.
89// </motivation>
90//
91// <todo asof="1996/07/24">
92// <li> Nothing known.
93// </todo>
94
95
97{
98public:
99 // Create with a <src>NORMAL</src> filter.
101 // Create with the supplied <src>filter</src>.
103
104 // Copy semantics - copy the filter from <src>other</src> to <src>this</src>
105 // <group>
108 // </group>
109
111
112 // Get/set the filter.
113 // <group>
114 virtual const LogFilterInterface &filter() const;
116 // </group>
117
118 // Get number of messages in sink.
119 virtual uInt nelements() const;
120
121 // Get given part of the i-th message from the sink.
122 // <group>
123 virtual Double getTime (uInt i) const;
124 virtual String getPriority (uInt i) const;
125 virtual String getMessage (uInt i) const;
126 virtual String getLocation (uInt i) const;
127 virtual String getObjectID (uInt i) const;
128 // </group>
129
130 // This function must be over-ridden in derived classes. If the filter
131 // passes the message, do what is necessary with the message and return
132 // <src>True</src>.
133 virtual Bool postLocally(const LogMessage &message)= 0;
134
135 // Write any pending output.
136 virtual void flush (Bool global=True);
137
138 // Write a message (usually from another logsink) into the local one.
139 // The default implementation does nothing.
140 virtual void writeLocally (Double time, const String& message,
141 const String& priority, const String& location,
142 const String& objectID);
143
144 // Clear the local sink (i.e. remove all messages from it).
145 // The default implementation does nothing.
146 virtual void clearLocally();
147
148 // Returns the id for this class...
149 static String localId( );
150 // Returns the id of the LogSink in use...
151 virtual String id( ) const = 0;
152 // Write to cerr too
153 virtual void cerrToo(bool cerr2);
154 void setTaskName(const String &theTask){taskName=theTask;}
155private:
157protected:
159};
160
161
162
163} //# NAMESPACE CASACORE - END
164
165#endif
LogSinkInterface(const LogSinkInterface &other)
Copy semantics - copy the filter from other to this
LogSinkInterface & operator=(const LogSinkInterface &)
virtual LogSinkInterface & filter(const LogFilterInterface &filter)
virtual void cerrToo(bool cerr2)
Write to cerr too.
virtual String getPriority(uInt i) const
LogFilterInterface * filter_p
virtual Double getTime(uInt i) const
Get given part of the i-th message from the sink.
virtual void flush(Bool global=True)
Write any pending output.
LogSinkInterface()
Create with a NORMAL filter.
virtual Bool postLocally(const LogMessage &message)=0
This function must be over-ridden in derived classes.
virtual String getLocation(uInt i) const
LogSinkInterface(const LogFilterInterface &filter)
Create with the supplied filter.
virtual const LogFilterInterface & filter() const
Get/set the filter.
virtual void writeLocally(Double time, const String &message, const String &priority, const String &location, const String &objectID)
Write a message (usually from another logsink) into the local one.
virtual String id() const =0
Returns the id of the LogSink in use...
virtual String getObjectID(uInt i) const
virtual String getMessage(uInt i) const
void setTaskName(const String &theTask)
virtual uInt nelements() const
Get number of messages in sink.
static String localId()
Returns the id for this class...
virtual void clearLocally()
Clear the local sink (i.e.
String: the storage and methods of handling collections of characters.
Definition String.h:223
this file contains all the compiler specific defines
Definition mainpage.dox:28
TableExprNode time(const TableExprNode &node)
Definition ExprNode.h:1584
unsigned int uInt
Definition aipstype.h:49
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
const Bool True
Definition aipstype.h:41
double Double
Definition aipstype.h:53