blob: bb926a4756faab66cf800df1efc66add3a5c26ef [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
31enum { SEVERITY_THRESHOLD = boost::log::trivial::warning };
32
33// register a global logger
34BOOST_LOG_INLINE_GLOBAL_LOGGER_DEFAULT(logger, boost::log::sources::severity_logger_mt<boost::log::trivial::severity_level>)
35
36// just a helper macro used by the macros below - don't use it in your code
37#define LOG(severity) BOOST_LOG_SEV(logger::get(), boost::log::trivial::severity)
38
39// ===== log macros =====
40#define LOG_TRACE LOG(trace)
41#define LOG_DEBUG LOG(debug)
42#define LOG_INFO LOG(info)
43#define LOG_WARNING LOG(warning)
44#define LOG_ERROR LOG(error)
45#define LOG_FATAL LOG(fatal)
46
47namespace ndn {
48namespace ntorrent {
49
50struct LoggingUtil {
51 static void init();
52 // Initialize the log for the application. THis method must be called in the main function in
53 // the application before any logging may be performed.
54};
55
56} // end ntorrent
57} // end ndn
58#endif // UTIL_LOGGING_HPP