blob: 15784ff92cadb7864fad8152d06bcf15da04cfd5 [file] [log] [blame]
Alexander Afanasyevc507ac22013-01-21 16:01:58 -08001/* -*- 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19 * Zhenkai Zhu <zhenkai@cs.ucla.edu>
20 */
21
22#ifndef LOGGING_H
23#define LOGGING_H
24
25#include "config.h"
26
27#ifdef HAVE_LOG4CXX
28
29#include <log4cxx/logger.h>
30
31#define INIT_LOGGER(name) \
32 static log4cxx::LoggerPtr staticModuleLogger = log4cxx::Logger::getLogger (name);
33
34#define _LOG_DEBUG(x) \
35 LOG4CXX_DEBUG(staticModuleLogger, x);
36
37#define _LOG_TRACE(x) \
38 LOG4CXX_TRACE(staticModuleLogger, x);
39
40#define _LOG_FUNCTION(x) \
41 LOG4CXX_TRACE(staticModuleLogger, __FUNCTION__ << "(" << x << ")");
42
43#define _LOG_FUNCTION_NOARGS \
44 LOG4CXX_TRACE(staticModuleLogger, __FUNCTION__ << "()");
45
46#define _LOG_ERROR(x) \
47 LOG4CXX_ERROR(staticModuleLogger, x);
48
49void
50INIT_LOGGERS ();
51
52#else
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 <boost/thread/thread.hpp>
64#include <boost/date_time/posix_time/posix_time.hpp>
65#include <iostream>
66
67#define _LOG_DEBUG(x) \
68 std::clog << boost::get_system_time () << " " << boost::this_thread::get_id () << " " << x << endl;
69
70#else
71#define _LOG_DEBUG(x)
72#endif
73
74#endif // HAVE_LOG4CXX
75
76#endif // LOGGING_H