]> git.sesse.net Git - casparcg/blobdiff - common/log.h
2.1.0: Added missing build events.
[casparcg] / common / log.h
index 859da6bf299cc2df10259827723b027d895ade94..eb6dfbef4576c7a357ec15200a01eec2350d3d60 100644 (file)
@@ -43,6 +43,7 @@ namespace caspar { namespace log {
        \r
 namespace internal{\r
 void init();\r
+std::wstring get_call_stack();\r
 }\r
 \r
 void add_file_sink(const std::wstring& folder);\r
@@ -91,27 +92,18 @@ BOOST_LOG_DECLARE_GLOBAL_LOGGER_INIT(logger, caspar_logger)
        BOOST_LOG_STREAM_WITH_PARAMS(::caspar::log::get_logger(),\\r
                (::boost::log::keywords::severity = ::caspar::log::lvl))\r
 \r
-#define CASPAR_LOG_CURRENT_EXCEPTION() \\r
-       try\\r
-       {CASPAR_LOG(error) << caspar::u16(boost::current_exception_diagnostic_information());}\\r
+#define CASPAR_LOG_CALL_STACK()        try{\\r
+               CASPAR_LOG(info) << L"callstack:\n" << caspar::log::internal::get_call_stack();\\r
+       }\\r
        catch(...){}\r
 \r
+#define CASPAR_LOG_CURRENT_EXCEPTION() try{\\r
+               CASPAR_LOG(error)  << caspar::u16(boost::current_exception_diagnostic_information()) << L"Caught at:\n" << caspar::log::internal::get_call_stack();\\r
+       }\\r
+       catch(...){}\r
+       \r
 void set_log_level(const std::wstring& lvl);\r
 \r
-template<typename T>\r
-inline void replace_nonprintable(std::basic_string<T, std::char_traits<T>, std::allocator<T>>& str, T with)\r
-{\r
-       std::locale loc;\r
-       std::replace_if(str.begin(), str.end(), [&](T c)->bool { return !std::isprint(c, loc) && c != '\r' && c != '\n'; }, with);\r
-}\r
-\r
-template<typename T>\r
-inline std::basic_string<T> replace_nonprintable_copy(std::basic_string<T, std::char_traits<T>, std::allocator<T>> str, T with)\r
-{\r
-       replace_nonprintable(str, with);\r
-       return str;\r
-}\r
-\r
 }}\r
 \r
 #if defined(_MSC_VER)\r