[89] | 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/helpers/mutex.h>
|
---|
| 23 | #include <exception>
|
---|
| 24 |
|
---|
| 25 | namespace log4cxx
|
---|
| 26 | {
|
---|
| 27 | namespace helpers
|
---|
| 28 | {
|
---|
| 29 | /**
|
---|
| 30 | This class used to output log statements from within the log4cxx package.
|
---|
| 31 |
|
---|
| 32 | <p>Log4cxx components cannot make log4cxx logging calls. However, it is
|
---|
| 33 | sometimes useful for the user to learn about what log4cxx is
|
---|
| 34 | doing. You can enable log4cxx internal logging by calling the
|
---|
| 35 | <b>#setInternalDebugging</b> method.
|
---|
| 36 |
|
---|
| 37 | <p>All log4cxx internal debug calls go to standard output
|
---|
| 38 | where as internal error messages are sent to
|
---|
| 39 | standard error output. All internal messages are prepended with
|
---|
| 40 | the string "log4cxx: ".
|
---|
| 41 | */
|
---|
| 42 | class LOG4CXX_EXPORT LogLog
|
---|
| 43 | {
|
---|
| 44 | private:
|
---|
| 45 | bool debugEnabled;
|
---|
| 46 |
|
---|
| 47 | /**
|
---|
| 48 | In quietMode not even errors generate any output.
|
---|
| 49 | */
|
---|
| 50 | bool quietMode;
|
---|
| 51 | Mutex mutex;
|
---|
| 52 | LogLog();
|
---|
| 53 | LogLog(const LogLog&);
|
---|
| 54 | LogLog& operator=(const LogLog&);
|
---|
| 55 | static LogLog& getInstance();
|
---|
| 56 |
|
---|
| 57 |
|
---|
| 58 | public:
|
---|
| 59 | /**
|
---|
| 60 | Allows to enable/disable log4cxx internal logging.
|
---|
| 61 | */
|
---|
| 62 | static void setInternalDebugging(bool enabled);
|
---|
| 63 |
|
---|
| 64 | /**
|
---|
| 65 | This method is used to output log4cxx internal debug
|
---|
| 66 | statements. Output goes to the standard output.
|
---|
| 67 | */
|
---|
| 68 | static void debug(const LogString& msg);
|
---|
| 69 | static void debug(const LogString& msg, const std::exception& e);
|
---|
| 70 |
|
---|
| 71 |
|
---|
| 72 | /**
|
---|
| 73 | This method is used to output log4cxx internal error
|
---|
| 74 | statements. There is no way to disable error statements.
|
---|
| 75 | Output goes to stderr.
|
---|
| 76 | */
|
---|
| 77 | static void error(const LogString& msg);
|
---|
| 78 | static void error(const LogString& msg, const std::exception& e);
|
---|
| 79 |
|
---|
| 80 |
|
---|
| 81 | /**
|
---|
| 82 | In quiet mode LogLog generates strictly no output, not even
|
---|
| 83 | for errors.
|
---|
| 84 |
|
---|
| 85 | @param quietMode <code>true</code> for no output.
|
---|
| 86 | */
|
---|
| 87 | static void setQuietMode(bool quietMode);
|
---|
| 88 |
|
---|
| 89 | /**
|
---|
| 90 | This method is used to output log4cxx internal warning
|
---|
| 91 | statements. There is no way to disable warning statements.
|
---|
| 92 | Output goes to stderr.
|
---|
| 93 | */
|
---|
| 94 | static void warn(const LogString& msg);
|
---|
| 95 | static void warn(const LogString& msg, const std::exception& e);
|
---|
| 96 |
|
---|
| 97 | private:
|
---|
| 98 | static void emit(const LogString& msg);
|
---|
| 99 | static void emit(const std::exception& ex);
|
---|
| 100 | };
|
---|
| 101 | } // namespace helpers
|
---|
| 102 | } // namespace log4cxx
|
---|
| 103 |
|
---|
| 104 | #define LOGLOG_DEBUG(log) { \
|
---|
| 105 | log4cxx::helpers::LogLog::debug(log) ; }
|
---|
| 106 |
|
---|
| 107 | #define LOGLOG_WARN(log) { \
|
---|
| 108 | log4cxx::helpers::LogLog::warn(log) ; }
|
---|
| 109 |
|
---|
| 110 | #define LOGLOG_ERROR(log) { \
|
---|
| 111 | log4cxx::helpers::LogLog::warn(log); }
|
---|
| 112 |
|
---|
| 113 | #endif //_LOG4CXX_HELPERS_LOG_LOG_H
|
---|