Alexander Afanasyev | fa2f662 | 2016-12-25 12:28:00 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2013-2016, Regents of the University of California. |
Alexander Afanasyev | c507ac2 | 2013-01-21 16:01:58 -0800 | [diff] [blame] | 4 | * |
Alexander Afanasyev | fa2f662 | 2016-12-25 12:28:00 -0800 | [diff] [blame] | 5 | * This file is part of ChronoShare, a decentralized file sharing application over NDN. |
Alexander Afanasyev | c507ac2 | 2013-01-21 16:01:58 -0800 | [diff] [blame] | 6 | * |
Alexander Afanasyev | fa2f662 | 2016-12-25 12:28:00 -0800 | [diff] [blame] | 7 | * ChronoShare is free software: you can redistribute it and/or modify it under the terms |
| 8 | * of the GNU General Public License as published by the Free Software Foundation, either |
| 9 | * version 3 of the License, or (at your option) any later version. |
Alexander Afanasyev | c507ac2 | 2013-01-21 16:01:58 -0800 | [diff] [blame] | 10 | * |
Alexander Afanasyev | fa2f662 | 2016-12-25 12:28:00 -0800 | [diff] [blame] | 11 | * ChronoShare is distributed in the hope that it will be useful, but WITHOUT ANY |
| 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 13 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. |
Alexander Afanasyev | c507ac2 | 2013-01-21 16:01:58 -0800 | [diff] [blame] | 14 | * |
Alexander Afanasyev | fa2f662 | 2016-12-25 12:28:00 -0800 | [diff] [blame] | 15 | * You should have received copies of the GNU General Public License along with |
| 16 | * ChronoShare, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 17 | * |
| 18 | * See AUTHORS.md for complete list of ChronoShare authors and contributors. |
Alexander Afanasyev | c507ac2 | 2013-01-21 16:01:58 -0800 | [diff] [blame] | 19 | */ |
| 20 | |
Alexander Afanasyev | 360f41f | 2016-12-25 13:20:21 -0800 | [diff] [blame] | 21 | #ifndef CHRONOSHARE_CORE_LOGGING_HPP |
| 22 | #define CHRONOSHARE_CORE_LOGGING_HPP |
Alexander Afanasyev | c507ac2 | 2013-01-21 16:01:58 -0800 | [diff] [blame] | 23 | |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 24 | #include "core/chronoshare-config.hpp" |
Alexander Afanasyev | c507ac2 | 2013-01-21 16:01:58 -0800 | [diff] [blame] | 25 | |
Alexander Afanasyev | c507ac2 | 2013-01-21 16:01:58 -0800 | [diff] [blame] | 26 | #include <log4cxx/logger.h> |
| 27 | |
Alexander Afanasyev | 360f41f | 2016-12-25 13:20:21 -0800 | [diff] [blame] | 28 | namespace ndn { |
| 29 | namespace chronoshare { |
| 30 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 31 | #define MEMBER_LOGGER static log4cxx::LoggerPtr staticModuleLogger; |
Alexander Afanasyev | 47cf2ef | 2013-01-28 15:13:47 -0800 | [diff] [blame] | 32 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 33 | #define INIT_MEMBER_LOGGER(className, name) \ |
| 34 | log4cxx::LoggerPtr className::staticModuleLogger = log4cxx::Logger::getLogger(name); |
Alexander Afanasyev | 47cf2ef | 2013-01-28 15:13:47 -0800 | [diff] [blame] | 35 | |
Alexander Afanasyev | c507ac2 | 2013-01-21 16:01:58 -0800 | [diff] [blame] | 36 | #define INIT_LOGGER(name) \ |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 37 | static log4cxx::LoggerPtr staticModuleLogger = log4cxx::Logger::getLogger(name); |
Alexander Afanasyev | c507ac2 | 2013-01-21 16:01:58 -0800 | [diff] [blame] | 38 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 39 | #define _LOG_DEBUG(x) LOG4CXX_DEBUG(staticModuleLogger, x); |
Alexander Afanasyev | c507ac2 | 2013-01-21 16:01:58 -0800 | [diff] [blame] | 40 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 41 | #define _LOG_TRACE(x) LOG4CXX_TRACE(staticModuleLogger, x); |
Alexander Afanasyev | c507ac2 | 2013-01-21 16:01:58 -0800 | [diff] [blame] | 42 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 43 | #define _LOG_FUNCTION(x) LOG4CXX_TRACE(staticModuleLogger, __FUNCTION__ << "(" << x << ")"); |
Alexander Afanasyev | c507ac2 | 2013-01-21 16:01:58 -0800 | [diff] [blame] | 44 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 45 | #define _LOG_FUNCTION_NOARGS LOG4CXX_TRACE(staticModuleLogger, __FUNCTION__ << "()"); |
Alexander Afanasyev | c507ac2 | 2013-01-21 16:01:58 -0800 | [diff] [blame] | 46 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 47 | #define _LOG_ERROR(x) LOG4CXX_ERROR(staticModuleLogger, x); |
Alexander Afanasyev | c507ac2 | 2013-01-21 16:01:58 -0800 | [diff] [blame] | 48 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 49 | #define _LOG_ERROR_COND(cond, x) \ |
| 50 | if (cond) { \ |
| 51 | _LOG_ERROR(x) \ |
| 52 | } |
Alexander Afanasyev | 49a30d0 | 2013-01-21 21:38:48 -0800 | [diff] [blame] | 53 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 54 | #define _LOG_DEBUG_COND(cond, x) \ |
| 55 | if (cond) { \ |
| 56 | _LOG_DEBUG(x) \ |
| 57 | } |
Alexander Afanasyev | 49a30d0 | 2013-01-21 21:38:48 -0800 | [diff] [blame] | 58 | |
Alexander Afanasyev | c507ac2 | 2013-01-21 16:01:58 -0800 | [diff] [blame] | 59 | void |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 60 | INIT_LOGGERS(); |
Alexander Afanasyev | c507ac2 | 2013-01-21 16:01:58 -0800 | [diff] [blame] | 61 | |
Alexander Afanasyev | 360f41f | 2016-12-25 13:20:21 -0800 | [diff] [blame] | 62 | } // chronoshare |
| 63 | } // ndn |
Alexander Afanasyev | c507ac2 | 2013-01-21 16:01:58 -0800 | [diff] [blame] | 64 | |
Alexander Afanasyev | 360f41f | 2016-12-25 13:20:21 -0800 | [diff] [blame] | 65 | #endif // CHRONOSHARE_CORE_LOGGING_HPP |