Skip to content

Commit

Permalink
smashme
Browse files Browse the repository at this point in the history
  • Loading branch information
Spudz76 committed Mar 24, 2019
1 parent 3fc33ac commit c45a094
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Summary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

static void print_cpu(xmrig::Config *config)
{
Log::i()->text(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") WHITE_BOLD("%s") " %s %s",
Log::i()->text(GREEN_BOLD(" * ") WHITE_BOLD("%-13s%s") " %s %s",
"CPU",
xmrig::Cpu::info()->brand(),
xmrig::Cpu::info()->isX64() ? GREEN_BOLD("x64") : RED_BOLD("-x64"),
Expand Down
5 changes: 4 additions & 1 deletion src/common/log/BasicLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,11 @@ void BasicLog::text(const char* fmt, va_list args)

void BasicLog::print(va_list args)
{
char buf[kBufferSize];
vsnprintf(buf, sizeof(buf) - 1, m_fmt, args);
snprintf(m_fmt, sizeof(m_fmt) - 1, "%s", buf);
BasicLog::stripColor();
if (vsnprintf(m_buf, sizeof(m_buf) - 1, m_fmt, args) <= 0) {
if (snprintf(m_buf, sizeof(m_buf) - 1, "%s", m_fmt) <= 0) {
return;
}

Expand Down
5 changes: 4 additions & 1 deletion src/common/log/ConsoleLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,11 @@ bool ConsoleLog::isWritable() const

void ConsoleLog::print(va_list args)
{
char buf[kBufferSize];
vsnprintf(buf, sizeof(buf) - 1, m_fmt, args);
snprintf(m_fmt, sizeof(m_fmt) - 1, "%s", buf);
ConsoleLog::stripColor();
m_uvBuf.len = vsnprintf(m_buf, sizeof(m_buf) - 1, m_fmt, args);
m_uvBuf.len = snprintf(m_buf, sizeof(m_buf) - 1, "%s", m_fmt);
if (m_uvBuf.len <= 0) {
return;
}
Expand Down
7 changes: 4 additions & 3 deletions src/common/log/FileLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,11 @@ void FileLog::message(Level level, const char* fmt, va_list args)
fmt,
Log::endl()
);
stripColor();

char *buf = new char[kBufferSize];
const int size = vsnprintf(buf, kBufferSize - 1, m_fmt, args);
vsnprintf(buf, kBufferSize - 1, m_fmt, args);
snprintf(m_fmt, sizeof(m_fmt) - 1, "%s", buf);
FileLog::stripColor();
const int size = snprintf(buf, kBufferSize - 1, "%s", m_fmt);

write(buf, size);
}
Expand Down
4 changes: 3 additions & 1 deletion src/common/log/SysLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ void SysLog::stripColor()

void SysLog::message(Level level, const char *fmt, va_list args)
{
snprintf(m_fmt, sizeof(m_fmt) - 1, "%s", fmt);
char buf[kBufferSize];
vsnprintf(buf, sizeof(buf) - 1, m_fmt, args);
snprintf(m_fmt, sizeof(m_fmt) - 1, "%s", buf);
SysLog::stripColor();
vsyslog(static_cast<int>(level), m_fmt, args);
}
Expand Down

0 comments on commit c45a094

Please sign in to comment.