Apache Log4cxx  Version 2.0.0
Loading...
Searching...
No Matches
loglog.h
Go to the documentation of this file.
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_HELPERS_LOG_LOG_H
19#define _LOG4CXX_HELPERS_LOG_LOG_H
20
21#include <log4cxx/logstring.h>
22#include <log4cxx/logger.h>
24
25namespace LOG4CXX_NS
26{
27namespace helpers
28{
29
41class LOG4CXX_EXPORT LogLog
42{
43 private:
44 LOG4CXX_DECLARE_PRIVATE_MEMBER_PTR(LogLogPrivate, m_priv)
45
46 friend class SingletonHolder<LogLog>;
47 LogLog();
48 LogLog(const LogLog&);
49 LogLog& operator=(const LogLog&);
50
51 public:
53
55
59 static bool isDebugEnabled();
60
64 static bool isDebugEnabledFor(const LabelPtr& category);
65
69 static bool isTraceEnabledFor(const LabelPtr& category);
70
74 static void setInternalDebugging(bool newValue);
75
79 static bool isColorEnabled();
80
84 static void setColorEnabled(bool newValue);
85
89 static void debug(const LogString& msg);
93 static void debug(const LogString& msg, const std::exception& e);
94
95
99 static void error(const LogString& msg);
103 static void error(const LogString& msg, const std::exception& ex);
104
108 static void trace(const LabelPtr& category, const LogString& msg);
109
110#if !LOG4CXX_LOGCHAR_IS_UTF8
114 static void trace(const LabelPtr& category, const std::string& msg);
115#endif
124 static void setQuietMode(bool newValue);
125
129 static void warn(const LogString& msg);
133 static void warn(const LogString& msg, const std::exception& ex);
134
138 static LabelPtr getCategory(const LogString& name);
139
143 static ObjectPtr _createInstance();
144};
145} // namespace helpers
146} // namespace log4cxx
147
148#if defined(LOGLOG_THRESHOLD) && LOGLOG_THRESHOLD <= 10000
165#define LOGLOG_DEBUG(category, message) { \
166 if (LOG4CXX_NS::helpers::LogLog::isDebugEnabledFor(category)) { \
167 LOG4CXX_NS::helpers::MessageBuffer buf; \
168 LOG4CXX_NS::helpers::LogLog::trace(category, buf.str(buf << message)); } }
169#else // !defined(LOGLOG_THRESHOLD) || 10000 < LOGLOG_THRESHOLD
170#define LOGLOG_DEBUG(category, message)
171#endif
172
173#if defined(LOGLOG_THRESHOLD) && LOGLOG_THRESHOLD <= 5000
189#define LOGLOG_TRACE(category, message) { \
190 if (LOG4CXX_NS::helpers::LogLog::isTraceEnabledFor(category)) { \
191 LOG4CXX_NS::helpers::MessageBuffer buf; \
192 LOG4CXX_NS::helpers::LogLog::trace(category, buf.str(buf << message)); } }
193#else // !defined(LOGLOG_THRESHOLD) || 5000 < LOGLOG_THRESHOLD
194#define LOGLOG_TRACE(category, message)
195#endif
196
201#define LOGLOG_WARN(message) { \
202 LOG4CXX_NS::helpers::MessageBuffer buf; \
203 LOG4CXX_NS::helpers::LogLog::warn(buf.str(buf << message)); }
204
209#define LOGLOG_ERROR(message) { \
210 LOG4CXX_NS::helpers::MessageBuffer buf; \
211 LOG4CXX_NS::helpers::LogLog::error(buf.str(buf << message)); }
212
213#endif //_LOG4CXX_HELPERS_LOG_LOG_H
LoggerPtr LabelPtr
Definition loglog.h:52
static void error(const LogString &msg)
Output msg to SystemErrWriter unconditionally.
static LabelPtr getCategory(const LogString &name)
A name category for internal logging.
static void setInternalDebugging(bool newValue)
Start/stop outputing debug messages if newValue is true/false respectively.
static void debug(const LogString &msg, const std::exception &e)
Output msg and ex.what() to SystemErrWriter if internal debug logging is enabled.
static void error(const LogString &msg, const std::exception &ex)
Output msg and ex.what() to SystemErrWriter unconditionally.
static void setColorEnabled(bool newValue)
Start/stop coloring message text if newValue is true/false respectively.
static void warn(const LogString &msg, const std::exception &ex)
Output msg and ex.what() to SystemErrWriter unconditionally.
static bool isDebugEnabled()
Are debug messages sent to SystemErrWriter?
static void trace(const LabelPtr &category, const LogString &msg)
Output msg to SystemErrWriter if internal debug logging is enabled.
static bool isDebugEnabledFor(const LabelPtr &category)
Are category debug messages sent to SystemErrWriter?
static void trace(const LabelPtr &category, const std::string &msg)
Output msg to SystemErrWriter if internal debug logging is enabled.
static ObjectPtr _createInstance()
Internal use only.
static bool isTraceEnabledFor(const LabelPtr &category)
Are category trace messages sent to SystemErrWriter?
static void warn(const LogString &msg)
Output msg to SystemErrWriter unconditionally.
static void debug(const LogString &msg)
Output msg to SystemErrWriter if internal debug logging is enabled.
static bool isColorEnabled()
Are messages output in color?
static void setQuietMode(bool newValue)
Change quiet mode to newValue.
Wraps any singleton object so it can be added to APRInitializer.
Definition singletonholder.h:32
std::basic_string< logchar > LogString
Definition logstring.h:51
std::shared_ptr< Logger > LoggerPtr
Definition provisionnode.h:28