admin
2023-03-07 8b06b1cbf112d55307ea8a6efe711db4e7506d89
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
 * AppenderSkeleton.hh
 *
 * Copyright 2001, LifeLine Networks BV (www.lifeline.nl). All rights reserved.
 * Copyright 2001, Bastiaan Bakker. All rights reserved.
 *
 * See the COPYING file for the terms of usage and distribution.
 */
 
#ifndef _LOG4CPP_APPENDERSKELETON_HH
#define _LOG4CPP_APPENDERSKELETON_HH
 
#include <log4cpp/Portability.hh>
#include <log4cpp/Appender.hh>
#include <log4cpp/Filter.hh>
 
namespace log4cpp {
 
    /**
     * AppenderSkeleton is a helper class, simplifying implementation of
     * Appenders: it already takes care of handling of Thresholds and 
     * Filters. 
     **/
    class LOG4CPP_EXPORT AppenderSkeleton : public Appender {
        protected:
        /**
         * Constructor for AppenderSkeleton. Will only be used in 
         * getAppender() (and in derived classes of course).
         * @param name The name of this Appender.
         **/
        AppenderSkeleton(const std::string& name);
 
        public:
        /**
         * Destructor for AppenderSkeleton.
         **/
        virtual ~AppenderSkeleton();
        
        /**
         * Log in Appender specific way. 
         * @param event  The LoggingEvent to log. 
         **/
        virtual void doAppend(const LoggingEvent& event);
 
        /**
         * Reopens the output destination of this Appender, e.g. the logfile 
         * or TCP socket.
         * @returns false if an error occured during reopening, true otherwise.
         **/
        virtual bool reopen();
 
        /**
         * Release any resources allocated within the appender such as file
         * handles, network connections, etc.
         **/
        virtual void close() = 0;
 
        /**
         * Check if the appender uses a layout.
         * 
         * @returns true if the appender implementation requires a layout.
         **/
        virtual bool requiresLayout() const = 0;
 
        /**
         * Set the Layout for this appender.
         * @param layout The layout to use.
         **/
        virtual void setLayout(Layout* layout) = 0;
 
        /**
         * Set the threshold priority of this Appender. The Appender will not
         * appender LoggingEvents with a priority lower than the threshold.
         * Use Priority::NOTSET to disable threshold checking.
         * @param priority The priority to set.
         **/
        virtual void setThreshold(Priority::Value priority);
 
        /**
         * Get the threshold priority of this Appender.
         * @returns the threshold
         **/
        virtual Priority::Value getThreshold();
 
        /**
         * Set a Filter for this appender. 
         **/
        virtual void setFilter(Filter* filter);
 
        /**
         * Get the Filter for this appender.
         * @returns the filter, or NULL if no filter has been set.
         **/
        virtual Filter* getFilter();
 
        protected:
        /**
         * Log in Appender specific way. Subclasses of Appender should
         * implement this method to perform actual logging.
         * @param event  The LoggingEvent to log. 
         **/
        virtual void _append(const LoggingEvent& event) = 0;
 
        
        private:
        Priority::Value _threshold;
        Filter* _filter;
    };
}
 
#endif // _LOG4CPP_APPENDERSKELETON_HH