log4shib 2.0.1
Loading...
Searching...
No Matches
Appender.hh
Go to the documentation of this file.
1/*
2 * Appender.hh
3 *
4 * Copyright 2000, LifeLine Networks BV (www.lifeline.nl). All rights reserved.
5 * Copyright 2000, Bastiaan Bakker. All rights reserved.
6 *
7 * See the COPYING file for the terms of usage and distribution.
8 */
9
10#ifndef _LOG4SHIB_APPENDER_HH
11#define _LOG4SHIB_APPENDER_HH
12
14#include <string>
15#include <map>
16#include <set>
17#include <stdarg.h>
18#include <sys/types.h>
19#include <sys/stat.h>
20#include <fcntl.h>
21#include <log4shib/Priority.hh>
22#include <log4shib/Layout.hh>
25
26namespace log4shib {
28
34 public:
35
42 static Appender* getAppender(const std::string& name);
43
48 static bool reopenAll();
49
54 static void closeAll();
55
56 protected:
62 Appender(const std::string& name);
63
64 public:
68 virtual ~Appender();
69
74 virtual void doAppend(const LoggingEvent& event) = 0;
75
81 virtual bool reopen() = 0;
82
87 virtual void close() = 0;
88
94 virtual bool requiresLayout() const = 0;
95
100 virtual void setLayout(Layout* layout) = 0;
101
106 inline const std::string& getName() const { return _name; };
107
114 virtual void setThreshold(Priority::Value priority) = 0;
115
121
125 virtual void setFilter(Filter* filter) = 0;
126
131 virtual Filter* getFilter() = 0;
132
133 private:
134 typedef std::map<std::string, Appender*> AppenderMap;
135
136 static AppenderMap* _allAppenders;
137 static threading::Mutex _appenderMapMutex;
138
139 static AppenderMap& _getAllAppenders();
140 static void _deleteAllAppenders();
141 static void _addAppender(Appender* appender);
142 static void _removeAppender(Appender* appender);
143
144 const std::string _name;
145 };
146
147 typedef std::set<Appender *> AppenderSet;
148}
149
150#endif // _LOG4SHIB_APPENDER_HH
#define LOG4SHIB_EXPORT
Definition Export.hh:11
virtual Filter * getFilter()=0
Get the Filter for this appender.
static void closeAll()
Call reopen() on all existing Appenders.
Definition Appender.cpp:52
const std::string & getName() const
Get the name of this appender.
Definition Appender.hh:106
virtual void setFilter(Filter *filter)=0
Set a Filter for this appender.
static bool reopenAll()
Call reopen() on all existing Appenders.
Definition Appender.cpp:41
virtual void close()=0
Release any resources allocated within the appender such as file handles, network connections,...
Appender(const std::string &name)
Constructor for Appender.
Definition Appender.cpp:70
virtual void setLayout(Layout *layout)=0
Set the Layout for this appender.
virtual void doAppend(const LoggingEvent &event)=0
Log in Appender specific way.
static Appender * getAppender(const std::string &name)
Get a pointer to an exitsing Appender.
Definition Appender.cpp:23
virtual Priority::Value getThreshold()=0
Get the threshold priority of this Appender.
virtual bool reopen()=0
Reopens the output destination of this Appender, e.g.
virtual void setThreshold(Priority::Value priority)=0
Set the threshold priority of this Appender.
virtual bool requiresLayout() const =0
Check if the appender uses a layout.
Users should extend this class to implement customized logging event filtering.
Definition Filter.hh:49
Extend this abstract class to create your own log layout format.
Definition Layout.hh:22
int Value
The type of Priority Values.
Definition Priority.hh:84
Definition PThreads.hh:29
The top level namespace for all 'Log for C++' types and classes.
Definition AbortAppender.hh:16
std::set< Appender * > AppenderSet
Definition Appender.hh:147
The internal representation of logging events.
Definition LoggingEvent.hh:32