blob: 6dbc930afa3b891e114402ab21a034e6853bed13 [file] [log] [blame]
Alexander Afanasyev4f9ea482012-03-15 11:57:29 -07001/* -*- 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>
Chaoyi Bian3e1eb162012-04-03 16:59:32 -070019 * Chaoyi Bian <bcy@pku.edu.cn>
Alexander Afanasyev4f9ea482012-03-15 11:57:29 -070020 * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
21 */
22
23#ifndef SYNC_LOG_H
24#define SYNC_LOG_H
25
Alexander Afanasyev181d7e52012-04-09 13:54:11 -070026#ifdef NS3_MODULE
27
28#include <ns3/log.h>
29
30#define INIT_LOGGER(name) NS_LOG_COMPONENT_DEFINE(name);
31
32#define _LOG_INFO(x) NS_LOG_INFO(x)
33
34#define _LOG_DEBUG(x) NS_LOG_DEBUG(x)
35
36#define _LOG_TRACE(x) NS_LOG_LOGIC(x)
37
38#define _LOG_FUNCTION(x) NS_LOG_FUNCTION(x)
39
40#define _LOG_FUNCTION_NOARGS NS_LOG_FUNCTION_NOARGS
41
42#else
43
Alexander Afanasyev4f9ea482012-03-15 11:57:29 -070044#ifdef HAVE_LOG4CXX
45
46#include <log4cxx/logger.h>
47
48#define INIT_LOGGER(name) \
49 static log4cxx::LoggerPtr staticModuleLogger = log4cxx::Logger::getLogger (name);
50
Alexander Afanasyev181d7e52012-04-09 13:54:11 -070051#define _LOG_INFO(x) \
52 LOG4CXX_INFO(staticModuleLogger, x);
53
54#define _LOG_DEBUG(x) \
Alexander Afanasyev4f9ea482012-03-15 11:57:29 -070055 LOG4CXX_DEBUG(staticModuleLogger, x);
56
57#define _LOG_TRACE(x) \
58 LOG4CXX_TRACE(staticModuleLogger, x);
59
60#define _LOG_FUNCTION(x) \
61 LOG4CXX_TRACE(staticModuleLogger, __FUNCTION__ << "(" << x << ")");
62
63#define _LOG_FUNCTION_NOARGS \
64 LOG4CXX_TRACE(staticModuleLogger, __FUNCTION__ << "()");
65
66void
67INIT_LOGGERS ();
68
69#else
70
71#define INIT_LOGGER(name)
72#define _LOG_FUNCTION(x)
73#define _LOG_FUNCTION_NOARGS
74#define _LOG_TRACE(x)
Alexander Afanasyev181d7e52012-04-09 13:54:11 -070075#define _LOG_INFO(x)
Alexander Afanasyev4f9ea482012-03-15 11:57:29 -070076#define INIT_LOGGERS(x)
77
78#ifdef _DEBUG
79
80#include <boost/thread/thread.hpp>
81#include <boost/date_time/posix_time/posix_time.hpp>
82#include <iostream>
83
84#define _LOG_DEBUG(x) \
85 std::clog << boost::get_system_time () << " " << boost::this_thread::get_id () << " " << x << endl;
86
87#else
88#define _LOG_DEBUG(x)
89#endif
90
91#endif // HAVE_LOG4CXX
92
Alexander Afanasyev181d7e52012-04-09 13:54:11 -070093#endif // NS3_MODULE
94
Alexander Afanasyev4f9ea482012-03-15 11:57:29 -070095#endif // SYNC_LOG_H