casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
LogFilter.h
Go to the documentation of this file.
00001 //# LogFilter.h: Filter LogMessages on message priority
00002 //# Copyright (C) 1996,2000,2003
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //#
00027 //# $Id: LogFilter.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $
00028 
00029 #ifndef CASA_LOGFILTER_H
00030 #define CASA_LOGFILTER_H
00031 
00032 //# Includes
00033 #include <casa/Logging/LogFilterInterface.h>
00034 
00035 
00036 namespace casa { //# NAMESPACE CASA - BEGIN
00037 
00038 // <summary>
00039 // Filter LogMessages on message priority.
00040 // </summary>
00041 
00042 // <use visibility=export>
00043 
00044 // <reviewed reviewer="wbrouw" date="1996/08/21" tests="" demos="dLogging.cc" tests="tLogging.cc">
00045 // </reviewed>
00046 
00047 // <prerequisite>
00048 //   <li> <linkto class="LogMessage">LogMessage</linkto>
00049 // </prerequisite>
00050 //
00051 // <etymology>
00052 // Log[Message] Filter.
00053 // </etymology>
00054 //
00055 // <synopsis>
00056 // The <src>LogFilter</src> class is used by the various log sink classes,
00057 // typically accessed through <linkto class="LogSink">LogSink</linkto>, to
00058 // decide whether a particular <linkto class="LogMessage">LogMessage</linkto>
00059 // should be accepted or rejected.
00060 //
00061 // Simple filtering is based on the messages priority.
00062 // In particular, you typically will choose to only pass messages greater
00063 // than or equal to  <src>NORMAL</src> in priority, but you might choose
00064 // <src>DEBUGGING</src> to see all messages, or <src>SEVERE</src> to only see
00065 // messages that report serious problems.
00066 // </synopsis>
00067 //
00068 // <example>
00069 // Suppose we wanted to change the global sink so that it prints all messages,
00070 // including debugging messages:
00071 // <srcblock>
00072 // LogFilter all(LogMessage::DEBUGGING);
00073 // LogSink::globalSink().filter(all);
00074 // </srcblock>
00075 // </example>
00076 //
00077 // <motivation>
00078 // </motivation>
00079 //
00080 //# <todo asof="1996/07/23">
00081 //# </todo>
00082 
00083 class LogFilter : public LogFilterInterface
00084 {
00085 public:
00086   // Construct a filter with the LOWEST priority that you want passed.  Thus
00087   // <src>DEBUGGING</src> passes everything. Note that it is not possible to
00088   // block <src>SEVERE</src> level messages, although you can use a
00089   // <linkto class="NullLogSink">NullLogSink</linkto> which will have
00090   // this effect.
00091   LogFilter (LogMessage::Priority lowest=LogMessage::NORMAL);
00092 
00093   // Copy <src>other</src> to <src>this</src>.
00094   // <group>
00095   LogFilter (const LogFilter& other);
00096   LogFilter& operator= (const LogFilter& other);
00097   // </group>
00098 
00099   virtual ~LogFilter();
00100 
00101   // Clone the object.
00102   virtual LogFilter* clone() const;
00103 
00104   // Return True if <src>message</src> passes this filter.
00105   virtual Bool pass (const LogMessage& message) const;
00106 
00107   // Return the lowest priority which will pass this filter.
00108   LogMessage::Priority lowestPriority() const;
00109 
00110 private:
00111   LogMessage::Priority lowest_p;
00112 };
00113 
00114 
00115 inline LogMessage::Priority LogFilter::lowestPriority() const
00116 {
00117   return lowest_p;
00118 }
00119 
00120 
00121 
00122 } //# NAMESPACE CASA - END
00123 
00124 #endif