casacore
Loading...
Searching...
No Matches
StreamLogSink.h
Go to the documentation of this file.
1//# StreamLogSink.h: Send log messages to an ostream.
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_STREAMLOGSINK_H
27#define CASA_STREAMLOGSINK_H
28
29#include <casacore/casa/aips.h>
30#include <casacore/casa/Logging/LogSinkInterface.h>
31
32#include <casacore/casa/iosfwd.h>
33
34namespace casacore { //# NAMESPACE CASACORE - BEGIN
35
36// <summary>
37// Send log messages to an ostream.
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=LogSinkInterface>LogSinkInterface</linkto>
47// <li> ostream
48// </prerequisite>
49//
50// <etymology>
51// "Stream" from the family of standard C++ I/O classes.
52// </etymology>
53//
54// <synopsis>
55// <src>StreamLogSink</src> is a straightforward
56// <linkto class=LogSinkInterface>LogSinkInterface</linkto> which sends its
57// messages to an <src>ostream</src> (typically <src>cerr</src>) which it is
58// given at construction time. It is not intended to be used directly, rather it
59// should be used through <linkto class=LogSink>LogSink</linkto>.
60// </synopsis>
61//
62// <example>
63// See <linkto file="Logging.h">Logging.h</linkto>.
64// </example>
65//
66// <motivation>
67// Writing to standard output or error will be a common way of displaying log
68// messages.
69// </motivation>
70//
71// <todo asof="1996/07/24">
72// <li> Nothing known.
73// </todo>
74
75
76
78public:
79 // Defaults to <src>cerr</src> if no stream is supplied. The caller is
80 // responsible for ensuring that the supplied <src>ostream</src> ostream
81 // lives at least as long as this sink. If not filter is supplied,
82 // <src>NORMAL</src> is used.
83 // <group>
84 explicit StreamLogSink(ostream *theStream = 0, bool deleteStream = false);
86 ostream *theStream = 0, bool deleteStream = false);
88 ostream *theStream = 0, bool deleteStream = false);
89 // </group>
90
91 // Make a copy of <src>other</src>. After copying, both objects will post
92 // to the same stream.
93 // <group>
96 // </group>
97
99
100 // Write <src>message</src> to the stream if it passes the filter. Works
101 // by calling <src>operator<<(ostream &,const LogMesssage&)</src>.
102 virtual Bool postLocally(const LogMessage &message);
103
104 // write any pending output.
105 virtual void flush (Bool global=True);
106
107 // Returns the id for this class...
108 static String localId( );
109 // Returns the id of the LogSink in use...
110 String id( ) const;
111
112private:
113 ostream *stream_p;
115};
116
117
118} //# NAMESPACE CASACORE - END
119
120#endif
Priority
An "importance" which is assigned to each LogMessage.
Definition LogMessage.h:102
virtual const LogFilterInterface & filter() const
Get/set the filter.
virtual void flush(Bool global=True)
write any pending output.
virtual Bool postLocally(const LogMessage &message)
Write message to the stream if it passes the filter.
StreamLogSink & operator=(const StreamLogSink &other)
StreamLogSink(const StreamLogSink &other)
Make a copy of other.
StreamLogSink(const LogFilterInterface &filter, ostream *theStream=0, bool deleteStream=false)
String id() const
Returns the id of the LogSink in use...
static String localId()
Returns the id for this class...
StreamLogSink(ostream *theStream=0, bool deleteStream=false)
Defaults to cerr if no stream is supplied.
StreamLogSink(LogMessage::Priority filter, ostream *theStream=0, bool deleteStream=false)
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
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
const Bool True
Definition aipstype.h:41