blob: 86e1bf0d84c0aee7cc1ff3de82fb99b3db449aa9 [file] [log] [blame]
Alexander Afanasyevfa2f6622016-12-25 12:28:00 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2013-2016, Regents of the University of California.
Alexander Afanasyevc507ac22013-01-21 16:01:58 -08004 *
Alexander Afanasyevfa2f6622016-12-25 12:28:00 -08005 * This file is part of ChronoShare, a decentralized file sharing application over NDN.
Alexander Afanasyevc507ac22013-01-21 16:01:58 -08006 *
Alexander Afanasyevfa2f6622016-12-25 12:28:00 -08007 * 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 Afanasyevc507ac22013-01-21 16:01:58 -080010 *
Alexander Afanasyevfa2f6622016-12-25 12:28:00 -080011 * 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 Afanasyevc507ac22013-01-21 16:01:58 -080014 *
Alexander Afanasyevfa2f6622016-12-25 12:28:00 -080015 * 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 Afanasyevc507ac22013-01-21 16:01:58 -080019 */
20
Alexander Afanasyev360f41f2016-12-25 13:20:21 -080021#ifndef CHRONOSHARE_CORE_LOGGING_HPP
22#define CHRONOSHARE_CORE_LOGGING_HPP
Alexander Afanasyevc507ac22013-01-21 16:01:58 -080023
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080024#include "core/chronoshare-config.hpp"
Alexander Afanasyevc507ac22013-01-21 16:01:58 -080025
Alexander Afanasyevc507ac22013-01-21 16:01:58 -080026#include <log4cxx/logger.h>
27
Alexander Afanasyev360f41f2016-12-25 13:20:21 -080028namespace ndn {
29namespace chronoshare {
30
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080031#define MEMBER_LOGGER static log4cxx::LoggerPtr staticModuleLogger;
Alexander Afanasyev47cf2ef2013-01-28 15:13:47 -080032
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080033#define INIT_MEMBER_LOGGER(className, name) \
34 log4cxx::LoggerPtr className::staticModuleLogger = log4cxx::Logger::getLogger(name);
Alexander Afanasyev47cf2ef2013-01-28 15:13:47 -080035
Alexander Afanasyevc507ac22013-01-21 16:01:58 -080036#define INIT_LOGGER(name) \
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080037 static log4cxx::LoggerPtr staticModuleLogger = log4cxx::Logger::getLogger(name);
Alexander Afanasyevc507ac22013-01-21 16:01:58 -080038
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080039#define _LOG_DEBUG(x) LOG4CXX_DEBUG(staticModuleLogger, x);
Alexander Afanasyevc507ac22013-01-21 16:01:58 -080040
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080041#define _LOG_TRACE(x) LOG4CXX_TRACE(staticModuleLogger, x);
Alexander Afanasyevc507ac22013-01-21 16:01:58 -080042
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080043#define _LOG_FUNCTION(x) LOG4CXX_TRACE(staticModuleLogger, __FUNCTION__ << "(" << x << ")");
Alexander Afanasyevc507ac22013-01-21 16:01:58 -080044
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080045#define _LOG_FUNCTION_NOARGS LOG4CXX_TRACE(staticModuleLogger, __FUNCTION__ << "()");
Alexander Afanasyevc507ac22013-01-21 16:01:58 -080046
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080047#define _LOG_ERROR(x) LOG4CXX_ERROR(staticModuleLogger, x);
Alexander Afanasyevc507ac22013-01-21 16:01:58 -080048
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080049#define _LOG_ERROR_COND(cond, x) \
50 if (cond) { \
51 _LOG_ERROR(x) \
52 }
Alexander Afanasyev49a30d02013-01-21 21:38:48 -080053
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080054#define _LOG_DEBUG_COND(cond, x) \
55 if (cond) { \
56 _LOG_DEBUG(x) \
57 }
Alexander Afanasyev49a30d02013-01-21 21:38:48 -080058
Alexander Afanasyevc507ac22013-01-21 16:01:58 -080059void
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080060INIT_LOGGERS();
Alexander Afanasyevc507ac22013-01-21 16:01:58 -080061
Alexander Afanasyev360f41f2016-12-25 13:20:21 -080062} // chronoshare
63} // ndn
Alexander Afanasyevc507ac22013-01-21 16:01:58 -080064
Alexander Afanasyev360f41f2016-12-25 13:20:21 -080065#endif // CHRONOSHARE_CORE_LOGGING_HPP