[89] | 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 | #if !defined(_LOG4CXX_ROLLING_ROLLING_POLICY_BASE_H)
|
---|
| 19 | #define _LOG4CXX_ROLLING_ROLLING_POLICY_BASE_H
|
---|
| 20 |
|
---|
| 21 | #if defined(_MSC_VER)
|
---|
| 22 | #pragma warning ( push )
|
---|
| 23 | #pragma warning ( disable: 4231 4251 4275 4786 )
|
---|
| 24 | #endif
|
---|
| 25 |
|
---|
| 26 |
|
---|
| 27 | #include <log4cxx/helpers/object.h>
|
---|
| 28 | #include <log4cxx/logger.h>
|
---|
| 29 | #include <log4cxx/logmanager.h>
|
---|
| 30 | #include <log4cxx/rolling/rollingpolicy.h>
|
---|
| 31 | #include <log4cxx/pattern/patternconverter.h>
|
---|
| 32 | #include <log4cxx/pattern/formattinginfo.h>
|
---|
| 33 | #include <log4cxx/pattern/patternparser.h>
|
---|
| 34 |
|
---|
| 35 | namespace log4cxx {
|
---|
| 36 | namespace rolling {
|
---|
| 37 | LOG4CXX_LIST_DEF(PatternConverterList, log4cxx::pattern::PatternConverterPtr);
|
---|
| 38 | LOG4CXX_LIST_DEF(FormattingInfoList, log4cxx::pattern::FormattingInfoPtr);
|
---|
| 39 |
|
---|
| 40 | /**
|
---|
| 41 | * Implements methods common to most, it not all, rolling
|
---|
| 42 | * policies.
|
---|
| 43 | *
|
---|
| 44 | *
|
---|
| 45 | *
|
---|
| 46 | */
|
---|
| 47 | class LOG4CXX_EXPORT RollingPolicyBase :
|
---|
| 48 | public virtual RollingPolicy,
|
---|
| 49 | public virtual helpers::ObjectImpl {
|
---|
| 50 | protected:
|
---|
| 51 | DECLARE_ABSTRACT_LOG4CXX_OBJECT(RollingPolicyBase)
|
---|
| 52 | BEGIN_LOG4CXX_CAST_MAP()
|
---|
| 53 | LOG4CXX_CAST_ENTRY(RollingPolicy)
|
---|
| 54 | LOG4CXX_CAST_ENTRY(spi::OptionHandler)
|
---|
| 55 | END_LOG4CXX_CAST_MAP()
|
---|
| 56 |
|
---|
| 57 |
|
---|
| 58 | private:
|
---|
| 59 | /**
|
---|
| 60 | * File name pattern converters.
|
---|
| 61 | */
|
---|
| 62 | PatternConverterList patternConverters;
|
---|
| 63 |
|
---|
| 64 | /**
|
---|
| 65 | * File name field specifiers.
|
---|
| 66 | */
|
---|
| 67 | FormattingInfoList patternFields;
|
---|
| 68 |
|
---|
| 69 | /**
|
---|
| 70 | * File name pattern.
|
---|
| 71 | */
|
---|
| 72 | LogString fileNamePatternStr;
|
---|
| 73 |
|
---|
| 74 |
|
---|
| 75 | public:
|
---|
| 76 | RollingPolicyBase();
|
---|
| 77 | virtual ~RollingPolicyBase();
|
---|
| 78 | void addRef() const;
|
---|
| 79 | void releaseRef() const;
|
---|
| 80 | virtual void activateOptions(log4cxx::helpers::Pool& p) = 0;
|
---|
| 81 | virtual log4cxx::pattern::PatternMap getFormatSpecifiers() const = 0;
|
---|
| 82 |
|
---|
| 83 | virtual void setOption(const LogString& option,
|
---|
| 84 | const LogString& value);
|
---|
| 85 |
|
---|
| 86 | /**
|
---|
| 87 | * Set file name pattern.
|
---|
| 88 | * @param fnp file name pattern.
|
---|
| 89 | */
|
---|
| 90 | void setFileNamePattern(const LogString& fnp);
|
---|
| 91 |
|
---|
| 92 | /**
|
---|
| 93 | * Get file name pattern.
|
---|
| 94 | * @return file name pattern.
|
---|
| 95 | */
|
---|
| 96 | LogString getFileNamePattern() const;
|
---|
| 97 |
|
---|
| 98 |
|
---|
| 99 | protected:
|
---|
| 100 | /**
|
---|
| 101 | * Parse file name pattern.
|
---|
| 102 | */
|
---|
| 103 | void parseFileNamePattern();
|
---|
| 104 |
|
---|
| 105 | /**
|
---|
| 106 | * Format file name.
|
---|
| 107 | *
|
---|
| 108 | * @param obj object to be evaluted in formatting, may not be null.
|
---|
| 109 | * @param buf string buffer to which formatted file name is appended, may not be null.
|
---|
| 110 | * @param p memory pool.
|
---|
| 111 | */
|
---|
| 112 | void formatFileName(log4cxx::helpers::ObjectPtr& obj,
|
---|
| 113 | LogString& buf, log4cxx::helpers::Pool& p) const;
|
---|
| 114 |
|
---|
| 115 | log4cxx::pattern::PatternConverterPtr getIntegerPatternConverter() const;
|
---|
| 116 | log4cxx::pattern::PatternConverterPtr getDatePatternConverter() const;
|
---|
| 117 |
|
---|
| 118 |
|
---|
| 119 | };
|
---|
| 120 | }
|
---|
| 121 | }
|
---|
| 122 |
|
---|
| 123 |
|
---|
| 124 | #if defined(_MSC_VER)
|
---|
| 125 | #pragma warning ( pop )
|
---|
| 126 | #endif
|
---|
| 127 |
|
---|
| 128 | #endif
|
---|