mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2024-12-24 11:54:01 +00:00
logger: add class for logging a scope's lifetime
This commit is contained in:
parent
7639fac210
commit
9a1f5290ba
@ -132,6 +132,19 @@ stderr_target_c::log_line(std::string const &message) {
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
lifetime_logger_c::lifetime_logger_c(std::string const &comment)
|
||||
: m_comment{comment}
|
||||
, m_start{mtx::sys::get_current_time_millis()}
|
||||
{
|
||||
target_c::get_default_logger() << fmt::format("lifetime log start for {0}\n", m_comment);
|
||||
}
|
||||
|
||||
lifetime_logger_c::~lifetime_logger_c() {
|
||||
target_c::get_default_logger() << fmt::format("lifetime log runtime +{0}ms for {1}\n", mtx::sys::get_current_time_millis() - m_start, m_comment);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void
|
||||
init() {
|
||||
s_program_start_time = QDateTime::currentDateTime();
|
||||
|
@ -43,6 +43,16 @@ public:
|
||||
static int64_t runtime();
|
||||
};
|
||||
|
||||
class lifetime_logger_c {
|
||||
private:
|
||||
std::string const m_comment;
|
||||
int64_t m_start{};
|
||||
|
||||
public:
|
||||
lifetime_logger_c(std::string const &comment);
|
||||
~lifetime_logger_c();
|
||||
};
|
||||
|
||||
class file_target_c: public target_c {
|
||||
private:
|
||||
std::filesystem::path m_file_name;
|
||||
@ -77,4 +87,5 @@ void init();
|
||||
}
|
||||
|
||||
#define log_current_location() mtx::log::target_c::get_default_logger() << fmt::format("Current file, line, function: {0}:{1} in {2}", __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
||||
#define log_scope_lifetime() mtx::log::lifetime_logger_c mtx_scope_lifetime_logger{fmt::format("{0}:{1} in {2}", __FILE__, __LINE__, __PRETTY_FUNCTION__)}
|
||||
#define log_it(arg) mtx::log::target_c::get_default_logger() << (arg)
|
||||
|
Loading…
Reference in New Issue
Block a user