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
57 static bool isDebugEnabled();
58
62 static bool isDebugEnabledFor(const LoggerPtr& category);
63
67 static bool isTraceEnabledFor(const LoggerPtr& category);
68
72 static void setInternalDebugging(bool newValue);
73
77 static bool isColorEnabled();
78
82 static void setColorEnabled(bool newValue);
83
87 static void debug(const LogString& msg);
91 static void debug(const LogString& msg, const std::exception& e);
92
93
97 static void error(const LogString& msg);
101 static void error(const LogString& msg, const std::exception& ex);
102
106 static void trace(const LoggerPtr& category, const LogString& msg);
107
108#if !LOG4CXX_LOGCHAR_IS_UTF8
112 static void trace(const LoggerPtr& category, const std::string& msg);
113#endif
122 static void setQuietMode(bool newValue);
123
127 static void warn(const LogString& msg);
131 static void warn(const LogString& msg, const std::exception& ex);
132
136 static LoggerPtr getLogger(const LogString& name);
137
141 static ObjectPtr _createInstance();
142};
143} // namespace helpers
144} // namespace log4cxx
145
146#if defined(LOGLOG_THRESHOLD) && LOGLOG_THRESHOLD <= 10000
163#define LOGLOG_DEBUG(logger, message) { \
164 if (LOG4CXX_NS::helpers::LogLog::isDebugEnabledFor(logger)) { \
165 LOG4CXX_NS::helpers::MessageBuffer buf; \
166 LOG4CXX_NS::helpers::LogLog::trace(logger, buf.str(buf << message)); } }
167#else // !defined(LOGLOG_THRESHOLD) || 10000 < LOGLOG_THRESHOLD
168#define LOGLOG_DEBUG(logger, message)
169#endif
170
171#if defined(LOGLOG_THRESHOLD) && LOGLOG_THRESHOLD <= 5000
187#define LOGLOG_TRACE(logger, message) { \
188 if (LOG4CXX_NS::helpers::LogLog::isTraceEnabledFor(logger)) { \
189 LOG4CXX_NS::helpers::MessageBuffer buf; \
190 LOG4CXX_NS::helpers::LogLog::trace(logger, buf.str(buf << message)); } }
191#else // !defined(LOGLOG_THRESHOLD) || 5000 < LOGLOG_THRESHOLD
192#define LOGLOG_TRACE(logger, message)
193#endif
194
199#define LOGLOG_WARN(message) { \
200 LOG4CXX_NS::helpers::MessageBuffer buf; \
201 LOG4CXX_NS::helpers::LogLog::warn(buf.str(buf << message)); }
202
207#define LOGLOG_ERROR(message) { \
208 LOG4CXX_NS::helpers::MessageBuffer buf; \
209 LOG4CXX_NS::helpers::LogLog::error(buf.str(buf << message)); }
210
211#endif //_LOG4CXX_HELPERS_LOG_LOG_H
static void error(const LogString &msg)
Output msg to SystemErrWriter unconditionally.
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 bool isTraceEnabledFor(const LoggerPtr &category)
Are category trace messages sent to SystemErrWriter?
static LoggerPtr getLogger(const LogString &name)
A name category for internal logging.
static void warn(const LogString &msg, const std::exception &ex)
Output msg and ex.what() to SystemErrWriter unconditionally.
static void trace(const LoggerPtr &category, const std::string &msg)
Output msg to SystemErrWriter if internal debug logging is enabled.
static bool isDebugEnabled()
Are debug messages sent to SystemErrWriter?
static ObjectPtr _createInstance()
Internal use only.
static void trace(const LoggerPtr &category, const LogString &msg)
Output msg to SystemErrWriter if internal debug logging is enabled.
static void warn(const LogString &msg)
Output msg to SystemErrWriter unconditionally.
static bool isDebugEnabledFor(const LoggerPtr &category)
Are category debug messages sent to SystemErrWriter?
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 logmanager.h:28