]> git.sesse.net Git - casparcg/commitdiff
Separated call trace to separate log file calltrace.log
authorHelge Norberg <helge.norberg@svt.se>
Wed, 16 Dec 2015 14:02:51 +0000 (15:02 +0100)
committerHelge Norberg <helge.norberg@svt.se>
Wed, 16 Dec 2015 14:02:51 +0000 (15:02 +0100)
common/log.cpp
common/log.h
shell/main.cpp

index d9e5ac89845069ff9458b910849847ec792812fd..78957b60a2e014731888c284b8f2fce335e9cc5f 100644 (file)
@@ -152,7 +152,7 @@ void init()
 
        auto stream_sink = boost::make_shared<stream_sink_type>(stream_backend);
        // Never log calltrace to console. The terminal is too slow, so the log queue will build up faster than consumed.
-       stream_sink->set_filter(boost::log::expressions::attr<log_category>("Channel") != log_category::call);
+       stream_sink->set_filter(category != log_category::call);
 
        bool print_all_characters = false;
        stream_sink->set_formatter(boost::bind(&my_formatter<boost::log::wformatting_ostream>, print_all_characters, _1, _2));
@@ -162,17 +162,17 @@ void init()
 
 }
 
-void add_file_sink(const std::wstring& folder)
+void add_file_sink(const std::wstring& file, const boost::log::filter& filter)
 {
        typedef boost::log::sinks::synchronous_sink<boost::log::sinks::text_file_backend> file_sink_type;
 
        try
        {
-               if (!boost::filesystem::is_directory(folder))
+               if (!boost::filesystem::is_directory(boost::filesystem::path(file).parent_path()))
                        CASPAR_THROW_EXCEPTION(directory_not_found());
 
                auto file_sink = boost::make_shared<file_sink_type>(
-                       boost::log::keywords::file_name = (folder + L"caspar_%Y-%m-%d.log"),
+                       boost::log::keywords::file_name = (file + L"_%Y-%m-%d.log"),
                        boost::log::keywords::time_based_rotation = boost::log::sinks::file::rotation_at_time_point(0, 0, 0),
                        boost::log::keywords::auto_flush = true,
                        boost::log::keywords::open_mode = std::ios::app
@@ -181,6 +181,7 @@ void add_file_sink(const std::wstring& folder)
                bool print_all_characters = true;
 
                file_sink->set_formatter(boost::bind(&my_formatter<boost::log::formatting_ostream>, print_all_characters, _1, _2));
+               file_sink->set_filter(filter);
                boost::log::core::get()->add_sink(file_sink);
        }
        catch (...)
index e786a8b84bf8b017804fe170cd634a6bd1b644c1..a4415c60f801253f03a5cd1853b60c8a183123bb 100644 (file)
@@ -26,6 +26,7 @@
 #include "thread_info.h"
 
 #include <boost/log/trivial.hpp>
+#include <boost/log/expressions.hpp>
 #include <boost/log/sources/global_logger_storage.hpp>
 #include <boost/log/sources/severity_channel_logger.hpp>
 #include <boost/exception/all.hpp>
@@ -63,7 +64,7 @@ inline std::basic_string<T> replace_nonprintable_copy(std::basic_string<T, std::
        return str;
 }
 
-void add_file_sink(const std::wstring& folder);
+void add_file_sink(const std::wstring& file, const boost::log::filter& filter);
 std::shared_ptr<void> add_preformatted_line_sink(std::function<void(std::string line)> formatted_line_sink);
 
 enum class log_category
@@ -72,6 +73,7 @@ enum class log_category
        call,
        communication
 };
+BOOST_LOG_ATTRIBUTE_KEYWORD(category, "Channel", ::caspar::log::log_category)
 
 typedef boost::log::sources::wseverity_channel_logger_mt<boost::log::trivial::severity_level, log_category> caspar_logger;
 
index ffac2a4cded2060ec96880f06b2942e9099070fc..2d957f21ff40fb334913d9a58ea5ef6d4220587a 100644 (file)
@@ -304,7 +304,8 @@ int main(int argc, char** argv)
                        wait_for_remote_debugging();
 
                // Start logging to file.
-               log::add_file_sink(env::log_folder());                  
+               log::add_file_sink(env::log_folder() + L"caspar",               caspar::log::category != caspar::log::log_category::call);
+               log::add_file_sink(env::log_folder() + L"calltrace",    caspar::log::category == caspar::log::log_category::call);
                std::wcout << L"Logging [info] or higher severity to " << env::log_folder() << std::endl << std::endl;
                
                // Setup console window.