1 | /*
|
---|
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
|
---|
3 | * contributor license agreements. See the NOTICE file distributed with
|
---|
4 | * this work for additional information regarding copyright ownership.
|
---|
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
|
---|
6 | * (the "License"); you may not use this file except in compliance with
|
---|
7 | * the License. You may obtain a copy of the License at
|
---|
8 | *
|
---|
9 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
10 | *
|
---|
11 | * Unless required by applicable law or agreed to in writing, software
|
---|
12 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
14 | * See the License for the specific language governing permissions and
|
---|
15 | * limitations under the License.
|
---|
16 | */
|
---|
17 |
|
---|
18 |
|
---|
19 | #if !defined(_LOG4CXX_ROLLING_TRIGGER_POLICY_H)
|
---|
20 | #define _LOG4CXX_ROLLING_TRIGGER_POLICY_H
|
---|
21 |
|
---|
22 |
|
---|
23 | #include <log4cxx/spi/optionhandler.h>
|
---|
24 | #include <log4cxx/helpers/objectimpl.h>
|
---|
25 | #include <log4cxx/spi/loggingevent.h>
|
---|
26 | #include <log4cxx/appender.h>
|
---|
27 |
|
---|
28 | namespace log4cxx {
|
---|
29 | class File;
|
---|
30 |
|
---|
31 | namespace rolling {
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * A <code>TriggeringPolicy</code> controls the conditions under which rollover
|
---|
35 | * occurs. Such conditions include time of day, file size, an
|
---|
36 | * external event or a combination thereof.
|
---|
37 | *
|
---|
38 | *
|
---|
39 | *
|
---|
40 | * */
|
---|
41 |
|
---|
42 | class LOG4CXX_EXPORT TriggeringPolicy :
|
---|
43 | public virtual spi::OptionHandler,
|
---|
44 | public virtual helpers::ObjectImpl {
|
---|
45 | DECLARE_ABSTRACT_LOG4CXX_OBJECT(TriggeringPolicy)
|
---|
46 | BEGIN_LOG4CXX_CAST_MAP()
|
---|
47 | LOG4CXX_CAST_ENTRY(TriggeringPolicy)
|
---|
48 | LOG4CXX_CAST_ENTRY(spi::OptionHandler)
|
---|
49 | END_LOG4CXX_CAST_MAP()
|
---|
50 | public:
|
---|
51 | virtual ~TriggeringPolicy();
|
---|
52 | void addRef() const;
|
---|
53 | void releaseRef() const;
|
---|
54 |
|
---|
55 | /**
|
---|
56 | * Determines if a rollover may be appropriate at this time. If
|
---|
57 | * true is returned, RolloverPolicy.rollover will be called but it
|
---|
58 | * can determine that a rollover is not warranted.
|
---|
59 | *
|
---|
60 | * @param appender A reference to the appender.
|
---|
61 | * @param event A reference to the currently event.
|
---|
62 | * @param filename The filename for the currently active log file.
|
---|
63 | * @param fileLength Length of the file in bytes.
|
---|
64 | * @return true if a rollover should occur.
|
---|
65 | */
|
---|
66 | virtual bool isTriggeringEvent(
|
---|
67 | Appender* appender,
|
---|
68 | const log4cxx::spi::LoggingEventPtr& event,
|
---|
69 | const LogString& filename,
|
---|
70 | size_t fileLength) = 0;
|
---|
71 |
|
---|
72 | };
|
---|
73 |
|
---|
74 | LOG4CXX_PTR_DEF(TriggeringPolicy);
|
---|
75 |
|
---|
76 |
|
---|
77 | }
|
---|
78 | }
|
---|
79 |
|
---|
80 | #endif
|
---|