mirror of
https://github.com/jwinterm/xmr-stak.git
synced 2026-11-22 10:53:56 +01:00
File logging option
This commit is contained in:
+19
@@ -155,6 +155,13 @@ printer* printer::oInst = nullptr;
|
||||
printer::printer()
|
||||
{
|
||||
verbose_level = LINF;
|
||||
logfile = nullptr;
|
||||
}
|
||||
|
||||
bool printer::open_logfile(const char* file)
|
||||
{
|
||||
logfile = fopen(file, "ab+");
|
||||
return logfile != nullptr;
|
||||
}
|
||||
|
||||
void printer::print_msg(verbosity verbose, const char* fmt, ...)
|
||||
@@ -185,10 +192,22 @@ void printer::print_msg(verbosity verbose, const char* fmt, ...)
|
||||
|
||||
std::unique_lock<std::mutex> lck(print_mutex);
|
||||
fputs(buf, stdout);
|
||||
|
||||
if(logfile != nullptr)
|
||||
{
|
||||
fputs(buf, logfile);
|
||||
fflush(logfile);
|
||||
}
|
||||
}
|
||||
|
||||
void printer::print_str(const char* str)
|
||||
{
|
||||
std::unique_lock<std::mutex> lck(print_mutex);
|
||||
fputs(str, stdout);
|
||||
|
||||
if(logfile != nullptr)
|
||||
{
|
||||
fputs(str, logfile);
|
||||
fflush(logfile);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user