log4tango 5.0.2
Appender.hh
Go to the documentation of this file.
1//
2// Appender.hh
3//
4// Copyright (C) : 2000 - 2002
5// LifeLine Networks BV (www.lifeline.nl). All rights reserved.
6// Bastiaan Bakker. All rights reserved.
7//
8// 2004,2005,2006,2007,2008,2009,2010,2011,2012
9// Synchrotron SOLEIL
10// L'Orme des Merisiers
11// Saint-Aubin - BP 48 - France
12//
13// This file is part of log4tango.
14//
15// Log4ango is free software: you can redistribute it and/or modify
16// it under the terms of the GNU Lesser General Public License as published by
17// the Free Software Foundation, either version 3 of the License, or
18// (at your option) any later version.
19//
20// Log4tango is distributed in the hope that it will be useful,
21// but WITHOUT ANY WARRANTY; without even the implied warranty of
22// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23// GNU Lesser General Public License for more details.
24//
25// You should have received a copy of the GNU Lesser General Public License
26// along with Log4Tango. If not, see <http://www.gnu.org/licenses/>.
27
29#include <string>
30#include <map>
31#include <set>
32#include <log4tango/Level.hh>
33#include <log4tango/Layout.hh>
36
37#ifndef _LOG4TANGO_APPENDER_H
38#define _LOG4TANGO_APPENDER_H
39
40namespace log4tango {
41
42//-----------------------------------------------------------------------------
43// class : Appender
44//-----------------------------------------------------------------------------
46{
47 friend class Logger;
48
49protected:
55 Appender (const std::string& name);
56
63 virtual void level_changed (Level::Value new_level);
64
65public:
69 virtual ~Appender ();
70
75#if defined(APPENDERS_HAVE_LEVEL_THRESHOLD) || defined(APPENDERS_HAVE_FILTERS)
76 int append (const LoggingEvent& event);
77#else
78 inline int append (const LoggingEvent& event) {
79 return _append(event);
80 }
81#endif
82
88 virtual bool reopen (void);
89
94 virtual void close (void) = 0;
95
101 virtual bool requires_layout (void) const = 0;
102
106 virtual void set_layout (Layout* layout = 0) = 0;
107
111 inline const std::string& get_name (void) const {
112 return _name;
113 }
114
122 virtual bool is_valid (void) const;
123
124#ifdef APPENDERS_HAVE_LEVEL_THRESHOLD
131 void set_level (Level::Value level);
132
137 Level::Value get_level (void) const;
138#endif // APPENDERS_HAVE_LEVEL_THRESHOLD
139
140#ifdef APPENDERS_HAVE_FILTERS
144 virtual void set_filter (Filter* filter);
145
150 virtual Filter* get_filter (void);
151#endif // APPENDERS_HAVE_FILTERS
152
153protected:
159 virtual int _append(const LoggingEvent& event) = 0;
160
161private:
165 const std::string _name;
166
167#ifdef APPENDERS_HAVE_LEVEL_THRESHOLD
171 Level::Value _level;
172#endif
173
174#ifdef APPENDERS_HAVE_FILTERS
178 Filter* _filter;
179#endif
180};
181
182} // namespace log4tango
183
184#endif // _LOG4TANGO_APPENDER_H
#define LOG4TANGO_EXPORT
Definition: Export.hh:38
Definition: Appender.hh:46
virtual bool requires_layout(void) const =0
Check if the appender uses a layout.
virtual void set_layout(Layout *layout=0)=0
Change the layout.
virtual int _append(const LoggingEvent &event)=0
Log in Appender specific way.
const std::string & get_name(void) const
Returns this appender name.
Definition: Appender.hh:111
int append(const LoggingEvent &event)
Log in Appender specific way.
Definition: Appender.hh:78
virtual void close(void)=0
Release any resources allocated within the appender such as file handles, network connections,...
Definition: Layout.hh:42
int Value
The type of Level Values.
Definition: Level.hh:98
Definition: Logger.hh:57
Definition: Appender.hh:40
The internal representation of logging events.
Definition: LoggingEvent.hh:51