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$ 00028 00029 #ifndef CASA_LOGFILTER_H 00030 #define CASA_LOGFILTER_H 00031 00032 //# Includes 00033 #include <casacore/casa/aips.h> 00034 #include <casacore/casa/Logging/LogFilterInterface.h> 00035 00036 00037 namespace casacore { //# NAMESPACE CASACORE - BEGIN 00038 00039 // <summary> 00040 // Filter LogMessages on message priority. 00041 // </summary> 00042 00043 // <use visibility=export> 00044 00045 // <reviewed reviewer="wbrouw" date="1996/08/21" tests="" demos="dLogging.cc" tests="tLogging.cc"> 00046 // </reviewed> 00047 00048 // <prerequisite> 00049 // <li> <linkto class="LogMessage">LogMessage</linkto> 00050 // </prerequisite> 00051 // 00052 // <etymology> 00053 // Log[Message] Filter. 00054 // </etymology> 00055 // 00056 // <synopsis> 00057 // The <src>LogFilter</src> class is used by the various log sink classes, 00058 // typically accessed through <linkto class="LogSink">LogSink</linkto>, to 00059 // decide whether a particular <linkto class="LogMessage">LogMessage</linkto> 00060 // should be accepted or rejected. 00061 // 00062 // Simple filtering is based on the messages priority. 00063 // In particular, you typically will choose to only pass messages greater 00064 // than or equal to <src>NORMAL</src> in priority, but you might choose 00065 // <src>DEBUGGING</src> to see all messages, or <src>SEVERE</src> to only see 00066 // messages that report serious problems. 00067 // </synopsis> 00068 // 00069 // <example> 00070 // Suppose we wanted to change the global sink so that it prints all messages, 00071 // including debugging messages: 00072 // <srcblock> 00073 // LogFilter all(LogMessage::DEBUGGING); 00074 // LogSink::globalSink().filter(all); 00075 // </srcblock> 00076 // </example> 00077 // 00078 // <motivation> 00079 // </motivation> 00080 // 00081 //# <todo asof="1996/07/23"> 00082 //# </todo> 00083 00084 class LogFilter : public LogFilterInterface 00085 { 00086 public: 00087 // Construct a filter with the LOWEST priority that you want passed. Thus 00088 // <src>DEBUGGING</src> passes everything. Note that it is not possible to 00089 // block <src>SEVERE</src> level messages, although you can use a 00090 // <linkto class="NullLogSink">NullLogSink</linkto> which will have 00091 // this effect. 00092 LogFilter (LogMessage::Priority lowest=LogMessage::NORMAL); 00093 00094 // Copy <src>other</src> to <src>this</src>. 00095 // <group> 00096 LogFilter (const LogFilter& other); 00097 LogFilter& operator= (const LogFilter& other); 00098 // </group> 00099 00100 virtual ~LogFilter(); 00101 00102 // Clone the object. 00103 virtual LogFilter* clone() const; 00104 00105 // Return True if <src>message</src> passes this filter. 00106 virtual Bool pass (const LogMessage& message) const; 00107 00108 // Return the lowest priority which will pass this filter. 00109 LogMessage::Priority lowestPriority() const; 00110 00111 private: 00112 LogMessage::Priority lowest_p; 00113 }; 00114 00115 00116 inline LogMessage::Priority LogFilter::lowestPriority() const 00117 { 00118 return lowest_p; 00119 } 00120 00121 00122 00123 } //# NAMESPACE CASACORE - END 00124 00125 #endif