2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
\r
4 * This file is part of CasparCG (www.casparcg.com).
\r
6 * CasparCG is free software: you can redistribute it and/or modify
\r
7 * it under the terms of the GNU General Public License as published by
\r
8 * the Free Software Foundation, either version 3 of the License, or
\r
9 * (at your option) any later version.
\r
11 * CasparCG is distributed in the hope that it will be useful,
\r
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 * GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License
\r
17 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
\r
19 * Author: Robert Nagy, ronag89@gmail.com
\r
24 #if defined(_MSC_VER)
\r
25 #pragma warning (push)
\r
26 #pragma warning (disable : 4100)
\r
27 #pragma warning (disable : 4127) // conditional expression is constant
\r
28 #pragma warning (disable : 4512)
\r
29 #pragma warning (disable : 4714) // marked as __forceinline not inlined
\r
30 #pragma warning (disable : 4996) // _CRT_SECURE_NO_WARNINGS
\r
33 #include <boost/log/detail/prologue.hpp>
\r
34 #include <boost/log/keywords/severity.hpp>
\r
35 #include <boost/log/sources/global_logger_storage.hpp>
\r
36 #include <boost/log/sources/severity_logger.hpp>
\r
37 #include <boost/log/sources/record_ostream.hpp>
\r
42 namespace caspar { namespace log {
\r
46 std::wstring get_call_stack();
\r
49 void add_file_sink(const std::wstring& folder);
\r
61 template< typename CharT, typename TraitsT >
\r
62 inline std::basic_ostream< CharT, TraitsT >& operator<< (
\r
63 std::basic_ostream< CharT, TraitsT >& strm, severity_level lvl)
\r
67 else if(lvl == debug)
\r
69 else if(lvl == info)
\r
71 else if(lvl == warning)
\r
73 else if(lvl == error)
\r
75 else if(lvl == fatal)
\r
78 strm << static_cast<int>(lvl);
\r
83 typedef boost::log::sources::wseverity_logger_mt<severity_level> caspar_logger;
\r
85 BOOST_LOG_DECLARE_GLOBAL_LOGGER_INIT(logger, caspar_logger)
\r
88 return caspar_logger(boost::log::keywords::severity = trace);
\r
91 #define CASPAR_LOG(lvl)\
\r
92 BOOST_LOG_STREAM_WITH_PARAMS(::caspar::log::get_logger(),\
\r
93 (::boost::log::keywords::severity = ::caspar::log::lvl))
\r
95 #define CASPAR_LOG_CALL_STACK() try{\
\r
96 CASPAR_LOG(info) << L"callstack:\n" << caspar::log::internal::get_call_stack();\
\r
100 #define CASPAR_LOG_CURRENT_EXCEPTION() try{\
\r
101 CASPAR_LOG(error) << caspar::u16(boost::current_exception_diagnostic_information()) << L"Caught at:\n" << caspar::log::internal::get_call_stack();\
\r
105 void set_log_level(const std::wstring& lvl);
\r
109 #if defined(_MSC_VER)
\r
110 #pragma warning (pop)
\r