-
Anonymous
Как правильно выйти из программы, использующей Boost Log?
Сообщение
Anonymous »
Пример программы ниже работает нормально, но valgrind показывает, что 520 байт в 6 блоках все еще доступны после выхода.
Код: Выделить всё
#include
#include
#include
#include
#include
#include
#include
namespace bl = boost::log;
namespace bp = boost::phoenix;
enum class MySeverityLevel
{
panic,
alert,
critical,
error,
warning,
notice,
info,
debug
};
BOOST_LOG_ATTRIBUTE_KEYWORD(Severity, "Severity", MySeverityLevel)
BOOST_LOG_ATTRIBUTE_KEYWORD(Channel, "Channel", std::string)
class Logger
{
public:
Logger(const std::string& CH, const MySeverityLevel SEV):
m_log(bl::keywords::channel = CH), m_channel(CH), m_severityMax(SEV)
{
m_sink = bl::add_file_log
(
bl::keywords::file_name = CH + ".log",
bl::keywords::filter = bp::bind(&Logger::filter, this, Channel.or_none(), Severity.or_none())
);
}
~Logger()
{
this->terminate();
}
void terminate()
{
if (m_sink)
{
bl::core::get()->remove_sink(m_sink);
m_sink->flush();
m_sink.reset();
}
}
void panic(const std::string& S)
{
BOOST_LOG_SEV(m_log, MySeverityLevel::panic)
Подробнее здесь: [url]https://stackoverflow.com/questions/54016819/how-to-correctly-exit-from-a-program-which-uses-boost-log[/url]
1731111739
Anonymous
Пример программы ниже работает нормально, но valgrind показывает, что 520 байт в 6 блоках все еще доступны после выхода.
[code]#include
#include
#include
#include
#include
#include
#include
namespace bl = boost::log;
namespace bp = boost::phoenix;
enum class MySeverityLevel
{
panic,
alert,
critical,
error,
warning,
notice,
info,
debug
};
BOOST_LOG_ATTRIBUTE_KEYWORD(Severity, "Severity", MySeverityLevel)
BOOST_LOG_ATTRIBUTE_KEYWORD(Channel, "Channel", std::string)
class Logger
{
public:
Logger(const std::string& CH, const MySeverityLevel SEV):
m_log(bl::keywords::channel = CH), m_channel(CH), m_severityMax(SEV)
{
m_sink = bl::add_file_log
(
bl::keywords::file_name = CH + ".log",
bl::keywords::filter = bp::bind(&Logger::filter, this, Channel.or_none(), Severity.or_none())
);
}
~Logger()
{
this->terminate();
}
void terminate()
{
if (m_sink)
{
bl::core::get()->remove_sink(m_sink);
m_sink->flush();
m_sink.reset();
}
}
void panic(const std::string& S)
{
BOOST_LOG_SEV(m_log, MySeverityLevel::panic)
Подробнее здесь: [url]https://stackoverflow.com/questions/54016819/how-to-correctly-exit-from-a-program-which-uses-boost-log[/url]