blob: e6a2b4b1af98deb5b7949028478c9adf53acc861 [file] [log] [blame]
Mickey Sweatt617d2d42016-04-25 22:02:08 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3* Copyright (c) 2016 Regents of the University of California.
4*
5* This file is part of the nTorrent codebase.
6*
7* nTorrent is free software: you can redistribute it and/or modify it under the
8* terms of the GNU Lesser General Public License as published by the Free Software
9* Foundation, either version 3 of the License, or (at your option) any later version.
10*
11* nTorrent 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 Lesser General Public License for more details.
14*
15* You should have received copies of the GNU General Public License and GNU Lesser
16* General Public License along with nTorrent, e.g., in COPYING.md file. If not, see
17* <http://www.gnu.org/licenses/>.
18*
19* See AUTHORS for complete list of nTorrent authors and contributors.
20*/
21#ifndef UTIL_LOGGING_HPP
22#define UTIL_LOGGING_HPP
23
24#define BOOST_LOG_DYN_LINK 1
25
26#include <boost/log/core.hpp>
27#include <boost/log/sources/global_logger_storage.hpp>
28#include <boost/log/sources/severity_logger.hpp>
29#include <boost/log/trivial.hpp>
30
Mickey Sweatt617d2d42016-04-25 22:02:08 -070031// register a global logger
32BOOST_LOG_INLINE_GLOBAL_LOGGER_DEFAULT(logger, boost::log::sources::severity_logger_mt<boost::log::trivial::severity_level>)
33
34// just a helper macro used by the macros below - don't use it in your code
35#define LOG(severity) BOOST_LOG_SEV(logger::get(), boost::log::trivial::severity)
36
37// ===== log macros =====
38#define LOG_TRACE LOG(trace)
39#define LOG_DEBUG LOG(debug)
40#define LOG_INFO LOG(info)
41#define LOG_WARNING LOG(warning)
42#define LOG_ERROR LOG(error)
43#define LOG_FATAL LOG(fatal)
44
45namespace ndn {
46namespace ntorrent {
47
Mickey Sweattec9188b2016-05-03 10:31:20 -070048namespace log = boost::log::trivial;
49
Mickey Sweatt617d2d42016-04-25 22:02:08 -070050struct LoggingUtil {
Mickey Sweattec9188b2016-05-03 10:31:20 -070051 static log::severity_level severity_threshold;
52
Mickey Sweatt617d2d42016-04-25 22:02:08 -070053 static void init();
54 // Initialize the log for the application. THis method must be called in the main function in
55 // the application before any logging may be performed.
56};
57
58} // end ntorrent
59} // end ndn
60#endif // UTIL_LOGGING_HPP