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_CONSOLE_APPENDER_H
|
---|
19 | #define _LOG4CXX_CONSOLE_APPENDER_H
|
---|
20 |
|
---|
21 | #include <log4cxx/writerappender.h>
|
---|
22 |
|
---|
23 | namespace log4cxx
|
---|
24 | {
|
---|
25 |
|
---|
26 | /**
|
---|
27 | * ConsoleAppender appends log events to <code>stdout</code> or
|
---|
28 | * <code>stderr</code> using a layout specified by the user. The
|
---|
29 | * default target is <code>stdout</code>.
|
---|
30 | */
|
---|
31 | class LOG4CXX_EXPORT ConsoleAppender : public WriterAppender
|
---|
32 | {
|
---|
33 | private:
|
---|
34 | LogString target;
|
---|
35 |
|
---|
36 | public:
|
---|
37 | DECLARE_LOG4CXX_OBJECT(ConsoleAppender)
|
---|
38 | BEGIN_LOG4CXX_CAST_MAP()
|
---|
39 | LOG4CXX_CAST_ENTRY(ConsoleAppender)
|
---|
40 | LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
|
---|
41 | END_LOG4CXX_CAST_MAP()
|
---|
42 |
|
---|
43 | ConsoleAppender();
|
---|
44 | ConsoleAppender(const LayoutPtr& layout);
|
---|
45 | ConsoleAppender(const LayoutPtr& layout, const LogString& target);
|
---|
46 | ~ConsoleAppender();
|
---|
47 |
|
---|
48 |
|
---|
49 | /**
|
---|
50 | * Sets the value of the <b>target</b> property. Recognized values
|
---|
51 | * are "System.out" and "System.err". Any other value will be
|
---|
52 | * ignored.
|
---|
53 | * */
|
---|
54 | void setTarget(const LogString& value);
|
---|
55 |
|
---|
56 | /**
|
---|
57 | * Returns the current value of the <b>target</b> property. The
|
---|
58 | * default value of the option is "System.out".
|
---|
59 | *
|
---|
60 | * See also #setTarget.
|
---|
61 | * */
|
---|
62 | LogString getTarget() const;
|
---|
63 |
|
---|
64 | void activateOptions(log4cxx::helpers::Pool& p);
|
---|
65 | void setOption(const LogString& option, const LogString& value);
|
---|
66 | static const LogString& getSystemOut();
|
---|
67 | static const LogString& getSystemErr();
|
---|
68 |
|
---|
69 |
|
---|
70 | private:
|
---|
71 | void targetWarn(const LogString& val);
|
---|
72 | static log4cxx::helpers::WriterPtr createWriter(const LogString& target);
|
---|
73 |
|
---|
74 | };
|
---|
75 | LOG4CXX_PTR_DEF(ConsoleAppender);
|
---|
76 | } //namespace log4cxx
|
---|
77 |
|
---|
78 | #endif //_LOG4CXX_CONSOLE_APPENDER_H
|
---|
79 |
|
---|