blob: 865204ab67c42d98718128ad260758a651a3a075 [file] [log] [blame]
akmhoque66e66182014-02-21 17:56:03 -06001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2012 University of California, Los Angeles
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
19 * Chaoyi Bian <bcy@pku.edu.cn>
20 * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
21 */
22
23#ifndef SYNC_LOG_H
24#define SYNC_LOG_H
25
26#ifdef HAVE_LOG4CXX
27
28#include <log4cxx/logger.h>
29
30#define INIT_LOGGER(name) \
31 static log4cxx::LoggerPtr staticModuleLogger = log4cxx::Logger::getLogger (name);
32
33#define _LOG_DEBUG(x) \
34 LOG4CXX_DEBUG(staticModuleLogger, x);
35
36#define _LOG_TRACE(x) \
37 LOG4CXX_TRACE(staticModuleLogger, x);
38
39#define _LOG_FUNCTION(x) \
40 LOG4CXX_TRACE(staticModuleLogger, __FUNCTION__ << "(" << x << ")");
41
42#define _LOG_FUNCTION_NOARGS \
43 LOG4CXX_TRACE(staticModuleLogger, __FUNCTION__ << "()");
44
45#define _LOG_ERROR(x) \
46 LOG4CXX_ERROR(staticModuleLogger, x);
47
48void
49INIT_LOGGERS ();
50
51#else
52
53#define INIT_LOGGER(name)
54#define _LOG_FUNCTION(x)
55#define _LOG_FUNCTION_NOARGS
56#define _LOG_TRACE(x)
57#define INIT_LOGGERS(x)
58#define _LOG_ERROR(x)
59
60#ifdef _DEBUG
61
62#include <boost/date_time/posix_time/posix_time.hpp>
63#include <iostream>
64
65#define _LOG_DEBUG(x) \
66 std::clog << boost::get_system_time () << " " << boost::this_thread::get_id () << " " << x << endl;
67
68#else
69#define _LOG_DEBUG(x)
70#endif
71
72#endif // HAVE_LOG4CXX
73
74#endif // SYNC_LOG_H