boost-log

Implementing an orthogonal log level that gets dumped into a socket

流过昼夜 提交于 2020-01-02 13:34:19
问题 I'm using boost log and want to implement an extra log level that is independent of the existing log levels. This log level will be activated on-demand, if there is a listening client connected to the daemons socket (independent of the current configured log level). Is this possible to implement? I suspect that the on-demand functionality can be implemented through a custom sink that will either discard, or send the data. But how do I integrate this with the rest of the logging code? 回答1: Let

Boost Thread Access Violation in Boost Log on shutdown

試著忘記壹切 提交于 2020-01-02 05:32:17
问题 I have an application that uses boost logging. During shutdown, it gets an access violation on a null pointer access. When I step through the code to the point of failure, it appears that the boost::log dll is being de-allocated and then boost::thread code tries to access the memory that was once occupied by the log dll. I am not using any boost threads in my own code, and so assume the boost-thread dll is used by boost log. To ensure all sinks are destroyed prior to shutdown, I am calling:

how to customize “TimeStamp” format of Boost.Log

邮差的信 提交于 2020-01-02 00:54:09
问题 I want to get year-month-day hour:minute:second.fraction(2 digits), if I use "%Y-%m-%d %H:%M:%S.%f", I got almost what I want exception for the fraction( last part ) of seconds, it's showing 6 digits on my Windows XP, I don't know how to get 2 digits only, any idea? 回答1: Boost.DateTime (upon which Boost.Log relies) doesn't seem to support specialized fractional seconds formatting, so the only way to do that would be to write your own custom attribute formatter, or (the easier, but less nice

boost log to print source code file name and line number

一世执手 提交于 2019-12-30 00:35:22
问题 I'm using Boost(1.55.0) Logging in my C++ application. I have been able to generate log of this format [2014-Jul-15 10:47:26.137959]: <debug> A regular message I want to be able to add source file name and line number where the log is generated. [2014-Jul-15 10:47:26.137959]: <debug> [filename:line_no] A regular message example: [2014-Jul-15 10:47:26.137959]: <debug> [helloworld.cpp : 12] A regular message Source Code: #include <boost/log/core.hpp> #include <boost/log/trivial.hpp> #include

boost log to print source code file name and line number

徘徊边缘 提交于 2019-12-30 00:35:08
问题 I'm using Boost(1.55.0) Logging in my C++ application. I have been able to generate log of this format [2014-Jul-15 10:47:26.137959]: <debug> A regular message I want to be able to add source file name and line number where the log is generated. [2014-Jul-15 10:47:26.137959]: <debug> [filename:line_no] A regular message example: [2014-Jul-15 10:47:26.137959]: <debug> [helloworld.cpp : 12] A regular message Source Code: #include <boost/log/core.hpp> #include <boost/log/trivial.hpp> #include

Boost Log 2.0 : empty Severity level in logs

前提是你 提交于 2019-12-29 03:52:06
问题 I'm using Boost-Log 2.0, which has some differences from version 1, and I have a hard time outputting the "Severity" attribute. I'm using the "Boost.Format-style" formatters "%TimeStamp% [%Uptime%] (%LineID%) <%Severity%>: %Message%" TimeStamp , LineID , and Message are common_attributes . Uptime is an attribute I added using attrs::timer() . I thought that Severity was automatically added when using severity_logger , but apparently it isn't and that's my problem. I get empty severities, eg:

How to output TimeStamp and ThreadID attributes with custom boost::log formatter?

孤街醉人 提交于 2019-12-23 20:35:30
问题 I'm using custom boost::log formatter for color coding the output log message, but I'm failing to find the proper way to add TimeStamp and ThreadID attributes to the log. When I'm using file logging I just write keywords::format = "[%TimeStamp%] [%ThreadID%] [%Severity%]: %Message%" as logging::add_file_log parameter. I want to have similar effect in the following custom formatter: void coloring_formatter(const logging::record_view& record, logging::formatting_ostream& stream) { auto severity

g++ static link error against Boost.Log

蹲街弑〆低调 提交于 2019-12-22 11:12:24
问题 I get link errors when statically linking against Boost.Log. The compiler version is g++ 4.8.1. Boost version is 1.55.0. I can do a dynamical link without problems (with a "-DBOOST_LOG_DYN_LINK" in make file) but when I do the static link, I get link errors. This problem won't happen on other boost libraries. I simplified my code to reproduce this issue easily: #include <boost/log/trivial.hpp> int main() { BOOST_LOG_TRIVIAL(trace) << "test trace"; return 0; } The build command that generates

How can I redirect output to a boost log?

核能气质少年 提交于 2019-12-22 10:17:08
问题 I have a C++ program that uses boost log, and I load a user-provided dynamic link library. I'd like to redirect stderr to the boost log, so that anytime the user's library does: std::cerr << "Some stuff"; It produces the same result** as: BOOST_LOG_SEV(log,info) << "Some stuff"; Is this possible, and if so then how do I do it? (Also, I'm not sure what to do about the severity... since cerr << doesn't privide severity information. I'm open to suggestions on that as well...) ** By "same result"

Different boost log sinks for every class

走远了吗. 提交于 2019-12-22 09:51:02
问题 I am new to boost log. My algorithm has 4 main steps and I want the logging for every step in one file. So that I have 4 sinks. My idea is that I can change the sink on every step. Is that possible? At the moment I have my looger.h with a global logger #ifndef LOGGER_H_ #define LOGGER_H_ #include <boost/shared_ptr.hpp> #include <boost/make_shared.hpp> #include <boost/thread/thread.hpp> #include <boost/log/core.hpp> #include <boost/log/sinks/sync_frontend.hpp> #include <boost/log/sinks/text