UHD 003.004.001-38-stable
include/uhd/utils/log.hpp
Go to the documentation of this file.
00001 //
00002 // Copyright 2011 Ettus Research LLC
00003 //
00004 // This program is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 //
00017 
00018 #ifndef INCLUDED_UHD_UTILS_LOG_HPP
00019 #define INCLUDED_UHD_UTILS_LOG_HPP
00020 
00021 #include <uhd/config.hpp>
00022 #include <uhd/utils/pimpl.hpp>
00023 #include <boost/current_function.hpp>
00024 #include <ostream>
00025 #include <string>
00026 
00057 #define UHD_LOGV(verbosity) \
00058     uhd::_log::log(uhd::_log::verbosity, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION)()
00059 
00064 #define UHD_LOG \
00065     UHD_LOGV(regularly)
00066 
00067 
00068 namespace uhd{ namespace _log{
00069 
00071     enum verbosity_t{
00072         always      = 1,
00073         often       = 2,
00074         regularly   = 3,
00075         rarely      = 4,
00076         very_rarely = 5,
00077         never       = 6,
00078     };
00079 
00081     class UHD_API log{
00082     public:
00083         log(
00084             const verbosity_t verbosity,
00085             const std::string &file,
00086             const unsigned int line,
00087             const std::string &function
00088         );
00089         ~log(void);
00090         std::ostream &operator()(void);
00091     private:
00092         UHD_PIMPL_DECL(impl) _impl;
00093     };
00094 
00095 }} //namespace uhd::_log
00096 
00097 #endif /* INCLUDED_UHD_UTILS_LOG_HPP */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines