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 | #ifndef _LOG4CXX_PATTERN_NAME_ABBREVIATOR
|
---|
19 | #define _LOG4CXX_PATTERN_NAME_ABBREVIATOR
|
---|
20 |
|
---|
21 | #include <log4cxx/logstring.h>
|
---|
22 | #include <log4cxx/helpers/objectptr.h>
|
---|
23 | #include <log4cxx/helpers/objectimpl.h>
|
---|
24 |
|
---|
25 | namespace log4cxx {
|
---|
26 | namespace pattern {
|
---|
27 |
|
---|
28 | class NameAbbreviator;
|
---|
29 | LOG4CXX_PTR_DEF(NameAbbreviator);
|
---|
30 |
|
---|
31 | /**
|
---|
32 | * NameAbbreviator generates abbreviated logger and class names.
|
---|
33 | *
|
---|
34 | *
|
---|
35 | *
|
---|
36 | */
|
---|
37 | class LOG4CXX_EXPORT NameAbbreviator : public log4cxx::helpers::ObjectImpl {
|
---|
38 | public:
|
---|
39 | DECLARE_ABSTRACT_LOG4CXX_OBJECT(NameAbbreviator)
|
---|
40 | BEGIN_LOG4CXX_CAST_MAP()
|
---|
41 | LOG4CXX_CAST_ENTRY(NameAbbreviator)
|
---|
42 | END_LOG4CXX_CAST_MAP()
|
---|
43 |
|
---|
44 | protected:
|
---|
45 | NameAbbreviator();
|
---|
46 |
|
---|
47 | public:
|
---|
48 | virtual ~NameAbbreviator();
|
---|
49 |
|
---|
50 | /**
|
---|
51 | * Gets an abbreviator.
|
---|
52 | *
|
---|
53 | * For example, "%logger{2}" will output only 2 elements of the logger name,
|
---|
54 | * "%logger{1.}" will output only the first character of the non-final elements in the name,
|
---|
55 | * "%logger(1~.2~} will output the first character of the first element, two characters of
|
---|
56 | * the second and subsequent elements and will use a tilde to indicate abbreviated characters.
|
---|
57 | *
|
---|
58 | * @param pattern abbreviation pattern.
|
---|
59 | * @return abbreviator, will not be null.
|
---|
60 | */
|
---|
61 | static NameAbbreviatorPtr getAbbreviator(const LogString& pattern);
|
---|
62 |
|
---|
63 | /**
|
---|
64 | * Gets default abbreviator.
|
---|
65 | *
|
---|
66 | * @return default abbreviator.
|
---|
67 | */
|
---|
68 | static NameAbbreviatorPtr getDefaultAbbreviator();
|
---|
69 |
|
---|
70 | /**
|
---|
71 | * Abbreviates a name in a StringBuffer.
|
---|
72 | *
|
---|
73 | * @param nameStart starting position of name in buf.
|
---|
74 | * @param buf buffer, may not be null.
|
---|
75 | */
|
---|
76 | virtual void abbreviate(LogString::size_type nameStart, LogString& buf) const = 0;
|
---|
77 |
|
---|
78 | };
|
---|
79 | }
|
---|
80 | }
|
---|
81 | #endif
|
---|