add WINIX_SAVE_FILELOG plugin message

This commit is contained in:
2022-09-01 07:34:10 +02:00
parent e09a93bd72
commit bff435db9a
4 changed files with 40 additions and 20 deletions

View File

@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2018-2019, Tomasz Sowa
* Copyright (c) 2018-2022, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -37,7 +37,7 @@
#include <string.h>
#include "utf8/utf8.h"
#include "timezones.h"
#include "plugin.h"
namespace Winix
@@ -49,6 +49,7 @@ FileLog::FileLog()
{
time_zones = nullptr;
synchro = nullptr;
plugin = nullptr;
log_time_zone_id = 0;
}
@@ -64,6 +65,12 @@ void FileLog::set_synchro(Synchro * synchro)
}
void FileLog::set_plugin(Plugin * plugin)
{
this->plugin = plugin;
}
void FileLog::init(const std::wstring & log_file, bool log_stdout, int log_level, bool save_each_line, size_t log_time_zone_id)
{
pt::FileLog::init(log_file, log_stdout, log_level, save_each_line);
@@ -116,19 +123,23 @@ pt::Date FileLog::get_local_date(const pt::Date & date)
bool FileLog::synchro_lock()
void FileLog::save_log(pt::WTextStream * buffer)
{
return synchro->Lock();
if( !buffer->empty() )
{
Lock lock(synchro);
pt::FileLog::save_log(buffer);
// at the beginning when winix starts the plugin pointer is null
// this plugin is set after the plugin object is initialized
if( plugin )
{
plugin->Call(WINIX_SAVE_FILELOG, buffer);
}
}
}
void FileLog::synchro_unlock()
{
synchro->Unlock();
}
} // namespace Winix