source: pacpusframework/trunk/3rd/apache-log4cxx/include/log4cxx/xml/xmllayout.h@ 184

Last change on this file since 184 was 89, checked in by morasjul, 12 years ago

PACPUS 2.0 Beta deployed in new branch

Major changes:
-Add communication interface between components
-Add examples for communications interface (TestComponents)
-Move to Qt5 support

  • Property svn:executable set to *
File size: 5.5 KB
Line 
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_XML_LAYOUT_H
19#define _LOG4CXX_XML_LAYOUT_H
20
21#include <log4cxx/layout.h>
22
23namespace log4cxx
24{
25 namespace xml
26 {
27
28 /**
29 The output of the XMLLayout consists of a series of log4j:event
30 elements. It does not output a
31 complete well-formed XML file. The output is designed to be
32 included as an <em>external entity</em> in a separate file to form
33 a correct XML file.
34
35 <p>For example, if <code>abc</code> is the name of the file where
36 the XMLLayout ouput goes, then a well-formed XML file would be:
37
38 <code>
39 <?xml version="1.0" ?>
40
41 <!DOCTYPE log4j:eventSet [<!ENTITY data SYSTEM "abc">]>
42
43 <log4j:eventSet version="1.2" xmlns:log4j="http://jakarta.apache.org/log4j/">
44
45 @&data;
46
47 </log4j:eventSet>
48 </code>
49
50 <p>This approach enforces the independence of the XMLLayout and the
51 appender where it is embedded.
52 */
53 class LOG4CXX_EXPORT XMLLayout : public Layout
54 {
55 private:
56
57 // Print no location info by default
58 bool locationInfo; //= false
59 bool properties; // = false
60
61 public:
62 DECLARE_LOG4CXX_OBJECT(XMLLayout)
63 BEGIN_LOG4CXX_CAST_MAP()
64 LOG4CXX_CAST_ENTRY(XMLLayout)
65 LOG4CXX_CAST_ENTRY_CHAIN(Layout)
66 END_LOG4CXX_CAST_MAP()
67
68 XMLLayout();
69
70 /**
71 The <b>LocationInfo</b> option takes a boolean value. By
72 default, it is set to false which means there will be no location
73 information output by this layout. If the the option is set to
74 true, then the file name and line number of the statement
75 at the origin of the log statement will be output.
76
77 <p>If you are embedding this layout within a SMTPAppender
78 then make sure to set the
79 <b>LocationInfo</b> option of that appender as well.
80 */
81 inline void setLocationInfo(bool locationInfo1)
82 { this->locationInfo = locationInfo1; }
83
84 /**
85 Returns the current value of the <b>LocationInfo</b> option.
86 */
87 inline bool getLocationInfo() const
88 { return locationInfo; }
89
90 /**
91 * Sets whether MDC key-value pairs should be output, default false.
92 * @param flag new value.
93 *
94 */
95 inline void setProperties(bool flag) {
96 properties = flag;
97 }
98
99 /**
100 * Gets whether MDC key-value pairs should be output.
101 * @return true if MDC key-value pairs are output.
102 *
103 */
104 inline bool getProperties() {
105 return properties;
106 }
107
108
109 /** No options to activate. */
110 void activateOptions(log4cxx::helpers::Pool& /* p */) { }
111
112 /**
113 Set options
114 */
115 virtual void setOption(const LogString& option,
116 const LogString& value);
117
118 /**
119 * Formats a {@link spi::LoggingEvent LoggingEvent}
120 * in conformance with the log4cxx.dtd.
121 **/
122 virtual void format(LogString& output,
123 const spi::LoggingEventPtr& event,
124 log4cxx::helpers::Pool& p) const;
125
126 /**
127 The XMLLayout prints and does not ignore exceptions. Hence the
128 return value <code>false</code>.
129 */
130 virtual bool ignoresThrowable() const
131 { return false; }
132
133 }; // class XMLLayout
134 LOG4CXX_PTR_DEF(XMLLayout);
135 } // namespace xml
136} // namespace log4cxx
137
138#endif // _LOG4CXX_XML_LAYOUT_H
Note: See TracBrowser for help on using the repository browser.