blob: 3e2d8dd14bb1d26b8abbb34ee095e460ab34bfc9 [file] [log] [blame]
Chengyu Fan71b712b2015-09-09 22:13:56 -06001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2012-2015 University of California, Los Angeles,
4 * 2015 Colorado State University
5 *
6 * This file is part of ChronoSync, synchronization library for distributed realtime
7 * applications for NDN.
8 *
9 * ChronoSync is free software: you can redistribute it and/or modify it under the terms
10 * of the GNU General Public License as published by the Free Software Foundation, either
11 * version 3 of the License, or (at your option) any later version.
12 *
13 * ChronoSync is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
14 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * ChronoSync, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * @author Zhenkai Zhu <http://irl.cs.ucla.edu/~zhenkai/>
21 * @author Chaoyi Bian <bcy@pku.edu.cn>
22 * @author Alexander Afanasyev <http://lasr.cs.ucla.edu/afanasyev/index.html>
23 * @author Chengyu Fan <chengyu@cs.colostate.edu>
24 */
25
26#ifndef ATMOS_CATALOG_LOGGER_HPP
27#define ATMOS_CATALOG_LOGGER_HPP
28
29#ifdef HAVE_LOG4CXX
30
31#include <log4cxx/logger.h>
32#include <log4cxx/propertyconfigurator.h>
33
34#define INIT_LOGGER(name) \
35 static log4cxx::LoggerPtr staticModuleLogger = log4cxx::Logger::getLogger(name)
36
37#define _LOG_DEBUG(x) \
38 LOG4CXX_DEBUG(staticModuleLogger, x)
39
40#define _LOG_TRACE(x) \
41 LOG4CXX_TRACE(staticModuleLogger, x)
42
43#define _LOG_FUNCTION(x) \
44 LOG4CXX_TRACE(staticModuleLogger, __FUNCTION__ << "(" << x << ")")
45
46#define _LOG_FUNCTION_NOARGS \
47 LOG4CXX_TRACE(staticModuleLogger, __FUNCTION__ << "()")
48
49#define _LOG_ERROR(x) \
50 LOG4CXX_ERROR(staticModuleLogger, x)
51
52#else // HAVE_LOG4CXX
53
54#define INIT_LOGGER(name)
55#define _LOG_FUNCTION(x)
56#define _LOG_FUNCTION_NOARGS
57#define _LOG_TRACE(x)
58#define INIT_LOGGERS(x)
59#define _LOG_ERROR(x)
60
61#ifdef _DEBUG
62
63#include <thread>
64#include <iostream>
65#include <ndn-cxx/util/time.hpp>
66
67// to print out messages, must be in debug mode
68#define _LOG_DEBUG(x) \
69 std::clog << ndn::time::system_clock::now() << " " << std::this_thread::get_id() << \
70 " " << x << std::endl
71
72#else // _DEBUG
73
74#define _LOG_DEBUG(x)
75
76#endif // _DEBUG
77
78#endif // HAVE_LOG4CXX
79
80#endif // ATMOS_CATALOG_LOGGER_HPP