remove FileLog::synchro_lock() and FileLog::synchro_unlock()
This commit is contained in:
parent
ce0348b2d7
commit
e501a3f4a3
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018-2021, Tomasz Sowa
|
* Copyright (c) 2018-2022, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -58,17 +58,6 @@ FileLog::~FileLog()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool FileLog::synchro_lock()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void FileLog::synchro_unlock()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void FileLog::init(const std::wstring & log_file, bool log_stdout, int log_level, bool save_each_line)
|
void FileLog::init(const std::wstring & log_file, bool log_stdout, int log_level, bool save_each_line)
|
||||||
{
|
{
|
||||||
this->log_stdout = log_stdout;
|
this->log_stdout = log_stdout;
|
||||||
|
@ -105,39 +94,28 @@ void FileLog::save_log(WTextStream * buffer)
|
||||||
if( buffer->empty() )
|
if( buffer->empty() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( synchro_lock() )
|
if( log_stdout )
|
||||||
{
|
{
|
||||||
try
|
wide_stream_to_utf8(*buffer, std::cout);
|
||||||
{
|
std::cout.flush();
|
||||||
if( log_stdout )
|
|
||||||
{
|
|
||||||
wide_stream_to_utf8(*buffer, std::cout);
|
|
||||||
std::cout.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !log_file.empty() )
|
|
||||||
{
|
|
||||||
if( !log_file_open || !file )
|
|
||||||
{
|
|
||||||
file.close();
|
|
||||||
file.clear();
|
|
||||||
|
|
||||||
open_file();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( file )
|
|
||||||
{
|
|
||||||
wide_stream_to_utf8(*buffer, file);
|
|
||||||
file.flush();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(...)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
synchro_unlock();
|
if( !log_file.empty() )
|
||||||
|
{
|
||||||
|
if( !log_file_open || !file )
|
||||||
|
{
|
||||||
|
file.close();
|
||||||
|
file.clear();
|
||||||
|
|
||||||
|
open_file();
|
||||||
|
}
|
||||||
|
|
||||||
|
if( file )
|
||||||
|
{
|
||||||
|
wide_stream_to_utf8(*buffer, file);
|
||||||
|
file.flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Tomasz Sowa
|
* Copyright (c) 2018-2022, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -79,9 +79,6 @@ protected:
|
||||||
// whether to save each line (for debug)
|
// whether to save each line (for debug)
|
||||||
bool save_each_line;
|
bool save_each_line;
|
||||||
|
|
||||||
|
|
||||||
virtual bool synchro_lock();
|
|
||||||
virtual void synchro_unlock();
|
|
||||||
virtual void open_file();
|
virtual void open_file();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue