New log support.

This commit is contained in:
XMRig 2019-03-27 01:29:37 +07:00
parent 17e9e036f1
commit f43929db98
26 changed files with 96 additions and 198 deletions

View file

@ -33,7 +33,6 @@ set(HEADERS
src/common/interfaces/IConfigCreator.h
src/common/interfaces/IControllerListener.h
src/common/interfaces/ICpuInfo.h
src/common/log/Log.h
src/common/Platform.h
src/common/utils/mm_malloc.h
src/common/xmrig.h

View file

@ -30,7 +30,7 @@
#include "App.h"
#include "common/log/Log.h"
#include "base/io/log/Log.h"
#include "core/Config.h"
#include "core/Controller.h"

View file

@ -28,7 +28,7 @@
#include <sys/mman.h>
#include "common/log/Log.h"
#include "base/io/log/Log.h"
#include "common/utils/mm_malloc.h"
#include "common/xmrig.h"
#include "crypto/CryptoNight.h"

View file

@ -30,7 +30,7 @@
#include <tchar.h>
#include "common/log/Log.h"
#include "base/io/log/Log.h"
#include "common/utils/mm_malloc.h"
#include "common/xmrig.h"
#include "crypto/CryptoNight.h"
@ -67,11 +67,11 @@ static BOOL SetLockPagesPrivilege() {
tp.PrivilegeCount = 1;
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
if (LookupPrivilegeValue(NULL, SE_LOCK_MEMORY_NAME, &(tp.Privileges[0].Luid)) != TRUE) {
if (LookupPrivilegeValue(nullptr, SE_LOCK_MEMORY_NAME, &(tp.Privileges[0].Luid)) != TRUE) {
return FALSE;
}
BOOL rc = AdjustTokenPrivileges(token, FALSE, (PTOKEN_PRIVILEGES) &tp, 0, NULL, NULL);
BOOL rc = AdjustTokenPrivileges(token, FALSE, (PTOKEN_PRIVILEGES) &tp, 0, nullptr, nullptr);
if (rc != TRUE || GetLastError() != ERROR_SUCCESS) {
return FALSE;
}
@ -95,12 +95,12 @@ static LSA_UNICODE_STRING StringToLsaUnicodeString(LPCTSTR string) {
static BOOL ObtainLockPagesPrivilege() {
HANDLE token;
PTOKEN_USER user = NULL;
PTOKEN_USER user = nullptr;
if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token) == TRUE) {
DWORD size = 0;
GetTokenInformation(token, TokenUser, NULL, 0, &size);
GetTokenInformation(token, TokenUser, nullptr, 0, &size);
if (size) {
user = (PTOKEN_USER) LocalAlloc(LPTR, size);
}
@ -118,7 +118,7 @@ static BOOL ObtainLockPagesPrivilege() {
ZeroMemory(&attributes, sizeof(attributes));
BOOL result = FALSE;
if (LsaOpenPolicy(NULL, &attributes, POLICY_ALL_ACCESS, &handle) == 0) {
if (LsaOpenPolicy(nullptr, &attributes, POLICY_ALL_ACCESS, &handle) == 0) {
LSA_UNICODE_STRING str = StringToLsaUnicodeString(_T(SE_LOCK_MEMORY_NAME));
if (LsaAddAccountRights(handle, user->User.Sid, &str, 1) == 0) {
@ -187,7 +187,7 @@ void Mem::release(MemInfo &info)
void *Mem::allocateExecutableMemory(size_t size)
{
return VirtualAlloc(0, size, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
return VirtualAlloc(nullptr, size, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
}

View file

@ -28,9 +28,9 @@
#include <uv.h>
#include "base/io/log/Log.h"
#include "base/net/stratum/Pool.h"
#include "common/cpu/Cpu.h"
#include "common/log/Log.h"
#include "core/Config.h"
#include "core/Controller.h"
#include "crypto/Asm.h"
@ -41,62 +41,44 @@
#ifndef XMRIG_NO_ASM
static const char *coloredAsmNames[] = {
"\x1B[1;31mnone\x1B[0m",
RED_BOLD("none"),
"auto",
"\x1B[1;32mintel\x1B[0m",
"\x1B[1;32mryzen\x1B[0m",
"\x1B[1;32mbulldozer\x1B[0m"
GREEN_BOLD("intel"),
GREEN_BOLD("ryzen"),
GREEN_BOLD("bulldozer")
};
inline static const char *asmName(xmrig::Assembly assembly, bool colors)
inline static const char *asmName(xmrig::Assembly assembly)
{
return colors ? coloredAsmNames[assembly] : xmrig::Asm::toString(assembly);
return coloredAsmNames[assembly];
}
#endif
static void print_memory(xmrig::Config *config) {
static void print_memory(xmrig::Config *) {
# ifdef _WIN32
if (config->isColors()) {
xmrig::Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") "%s",
"HUGE PAGES", Mem::isHugepagesAvailable() ? "\x1B[1;32mavailable" : "\x1B[01;31munavailable");
}
else {
xmrig::Log::print(" * %-13s%s", "HUGE PAGES", Mem::isHugepagesAvailable() ? "available" : "unavailable");
}
xmrig::Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") "%s",
"HUGE PAGES", Mem::isHugepagesAvailable() ? GREEN_BOLD("available") : RED_BOLD("unavailable"));
# endif
}
static void print_cpu(xmrig::Config *config)
static void print_cpu(xmrig::Config *)
{
using namespace xmrig;
if (config->isColors()) {
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s%s (%d)") " %sx64 %sAES %sAVX2",
"CPU",
Cpu::info()->brand(),
Cpu::info()->sockets(),
Cpu::info()->isX64() ? "\x1B[1;32m" : "\x1B[1;31m-",
Cpu::info()->hasAES() ? "\x1B[1;32m" : "\x1B[1;31m-",
Cpu::info()->hasAVX2() ? "\x1B[1;32m" : "\x1B[1;31m-");
# ifndef XMRIG_NO_LIBCPUID
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s%.1f MB/%.1f MB"), "CPU L2/L3", Cpu::info()->L2() / 1024.0, Cpu::info()->L3() / 1024.0);
# endif
}
else {
Log::print(" * %-13s%s (%d) %sx64 %sAES %sAVX2",
"CPU",
Cpu::info()->brand(),
Cpu::info()->sockets(),
Cpu::info()->isX64() ? "" : "-",
Cpu::info()->hasAES() ? "" : "-",
Cpu::info()->hasAVX2() ? "" : "-");
# ifndef XMRIG_NO_LIBCPUID
Log::print(" * %-13s%.1f MB/%.1f MB", "CPU L2/L3", Cpu::info()->L2() / 1024.0, Cpu::info()->L3() / 1024.0);
# endif
}
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s%s (%d)") " %sx64 %sAES %sAVX2",
"CPU",
Cpu::info()->brand(),
Cpu::info()->sockets(),
Cpu::info()->isX64() ? GREEN_BOLD_S : RED_BOLD("-"),
Cpu::info()->hasAES() ? GREEN_BOLD_S : RED_BOLD("-"),
Cpu::info()->hasAVX2() ? GREEN_BOLD_S : RED_BOLD("-")
);
# ifndef XMRIG_NO_LIBCPUID
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s%.1f MB/%.1f MB"), "CPU L2/L3", Cpu::info()->L2() / 1024.0, Cpu::info()->L3() / 1024.0);
# endif
}
@ -108,43 +90,42 @@ static void print_threads(xmrig::Config *config)
snprintf(buf, sizeof buf, ", affinity=0x%" PRIX64, config->affinity());
}
xmrig::Log::print(config->isColors() ? GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN_BOLD("%d") WHITE_BOLD(", %s, av=%d, %sdonate=%d%%") WHITE_BOLD("%s")
: " * %-13s%d, %s, av=%d, %sdonate=%d%%%s",
"THREADS",
config->threadsCount(),
config->algorithm().name(),
config->algoVariant(),
config->isColors() && config->pools().donateLevel() == 0 ? "\x1B[1;31m" : "",
config->pools().donateLevel(),
buf);
xmrig::Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN_BOLD("%d") WHITE_BOLD(", %s, av=%d, %sdonate=%d%%") WHITE_BOLD("%s"),
"THREADS",
config->threadsCount(),
config->algorithm().shortName(),
config->algoVariant(),
config->pools().donateLevel() == 0 ? RED_BOLD_S : "",
config->pools().donateLevel(),
buf
);
}
else {
xmrig::Log::print(config->isColors() ? GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN_BOLD("%d") WHITE_BOLD(", %s, %sdonate=%d%%")
: " * %-13s%d, %s, %sdonate=%d%%",
"THREADS",
config->threadsCount(),
config->algorithm().name(),
config->isColors() && config->pools().donateLevel() == 0 ? "\x1B[1;31m" : "",
config->pools().donateLevel());
xmrig::Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN_BOLD("%d") WHITE_BOLD(", %s, %sdonate=%d%%"),
"THREADS",
config->threadsCount(),
config->algorithm().shortName(),
config->pools().donateLevel() == 0 ? RED_BOLD_S : "",
config->pools().donateLevel()
);
}
# ifndef XMRIG_NO_ASM
if (config->assembly() == xmrig::ASM_AUTO) {
const xmrig::Assembly assembly = xmrig::Cpu::info()->assembly();
xmrig::Log::print(config->isColors() ? GREEN_BOLD(" * ") WHITE_BOLD("%-13sauto:%s")
: " * %-13sauto:%s", "ASSEMBLY", asmName(assembly, config->isColors()));
xmrig::Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13sauto:%s"), asmName(assembly));
}
else {
xmrig::Log::print(config->isColors() ? GREEN_BOLD(" * ") WHITE_BOLD("%-13s%s") : " * %-13s%s", "ASSEMBLY", asmName(config->assembly(), config->isColors()));
xmrig::Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s%s"), asmName(config->assembly()));
}
# endif
}
static void print_commands(xmrig::Config *config)
static void print_commands(xmrig::Config *)
{
if (config->isColors()) {
if (xmrig::Log::colors) {
xmrig::Log::print(GREEN_BOLD(" * ") WHITE_BOLD("COMMANDS ") MAGENTA_BOLD("h") WHITE_BOLD("ashrate, ")
MAGENTA_BOLD("p") WHITE_BOLD("ause, ")
MAGENTA_BOLD("r") WHITE_BOLD("esume"));

View file

@ -37,12 +37,12 @@
#endif
#include "base/io/log/Log.h"
#include "base/kernel/interfaces/IClientListener.h"
#include "base/net/dns/Dns.h"
#include "base/net/stratum/Client.h"
#include "base/tools/Buffer.h"
#include "base/tools/Chrono.h"
#include "common/log/Log.h"
#include "net/JobResult.h"
#include "rapidjson/document.h"
#include "rapidjson/error/en.h"

View file

@ -35,7 +35,7 @@
#ifdef APP_DEBUG
# include "common/log/Log.h"
# include "base/io/log/Log.h"
#endif

View file

@ -23,10 +23,10 @@
*/
#include "base/io/log/Log.h"
#include "base/net/stratum/Pools.h"
#include "base/net/stratum/strategies/FailoverStrategy.h"
#include "base/net/stratum/strategies/SinglePoolStrategy.h"
#include "common/log/Log.h"
#include "donate.h"
#include "rapidjson/document.h"
@ -161,25 +161,12 @@ void xmrig::Pools::print() const
{
size_t i = 1;
for (const Pool &pool : m_data) {
if (Log::colors) {
const int color = pool.isEnabled() ? (pool.isTLS() ? 32 : 36) : 31;
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("POOL #%-7zu") "\x1B[1;%dm%s\x1B[0m variant " WHITE_BOLD("%s"),
i,
color,
pool.url().data(),
pool.algorithm().variantName()
);
}
else {
Log::print(" * POOL #%-7zu%s%s variant=%s %s",
i,
pool.isEnabled() ? "" : "-",
pool.url().data(),
pool.algorithm().variantName(),
pool.isTLS() ? "TLS" : ""
);
}
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("POOL #%-7zu") CSI "1;%dm%s" CLEAR " variant " WHITE_BOLD("%s"),
i,
(pool.isEnabled() ? (pool.isTLS() ? 32 : 36) : 31),
pool.url().data(),
pool.algorithm().variantName()
);
i++;
}

View file

@ -27,10 +27,10 @@
#include <assert.h>
#include "base/io/log/Log.h"
#include "base/net/stratum/Client.h"
#include "base/net/stratum/Tls.h"
#include "base/tools/Buffer.h"
#include "common/log/Log.h"
#ifdef _MSC_VER

View file

@ -29,7 +29,7 @@
#include <uv.h>
#include "log/Log.h"
#include "base/io/log/Log.h"
#include "Platform.h"
#include "version.h"

View file

@ -28,12 +28,12 @@
#include "api/Api.h"
#include "base/io/log/Log.h"
#include "base/tools/Handle.h"
#include "base/tools/Timer.h"
#include "common/api/Httpd.h"
#include "common/api/HttpReply.h"
#include "common/api/HttpRequest.h"
#include "common/log/Log.h"
xmrig::Httpd::Httpd(int port, const char *accessToken, bool IPv6, bool restricted) :

View file

@ -55,8 +55,8 @@
#include "base/io/Json.h"
#include "base/io/log/Log.h"
#include "common/config/CommonConfig.h"
#include "common/log/Log.h"
#include "rapidjson/document.h"
#include "rapidjson/filewritestream.h"
#include "rapidjson/prettywriter.h"
@ -80,12 +80,6 @@ xmrig::CommonConfig::CommonConfig() :
}
bool xmrig::CommonConfig::isColors() const
{
return Log::colors;
}
void xmrig::CommonConfig::printAPI()
{
# ifndef XMRIG_NO_API
@ -93,9 +87,7 @@ void xmrig::CommonConfig::printAPI()
return;
}
Log::print(isColors() ? GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN("%s:") CYAN_BOLD("%d")
: " * %-13s%s:%d",
"API BIND", isApiIPv6() ? "[::]" : "0.0.0.0", apiPort());
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN("%s:") CYAN_BOLD("%d"), "API BIND", isApiIPv6() ? "[::]" : "0.0.0.0", apiPort());
# endif
}
@ -118,9 +110,7 @@ void xmrig::CommonConfig::printVersions()
snprintf(buf, sizeof buf, "MSVC/%d", MSVC_VERSION);
# endif
Log::print(isColors() ? GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN_BOLD("%s/%s") WHITE_BOLD(" %s")
: " * %-13s%s/%s %s",
"ABOUT", APP_NAME, APP_VERSION, buf);
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN_BOLD("%s/%s") WHITE_BOLD(" %s"), "ABOUT", APP_NAME, APP_VERSION, buf);
# if defined(XMRIG_AMD_PROJECT)
# if CL_VERSION_2_0
@ -157,9 +147,7 @@ void xmrig::CommonConfig::printVersions()
length += snprintf(buf + length, (sizeof buf) - length, "microhttpd/%s ", MHD_get_version());
# endif
Log::print(isColors() ? GREEN_BOLD(" * ") WHITE_BOLD("%-13slibuv/%s %s")
: " * %-13slibuv/%s %s",
"LIBS", uv_version_string(), buf);
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13slibuv/%s %s"), "LIBS", uv_version_string(), buf);
}

View file

@ -61,7 +61,6 @@ public:
bool save() override;
bool isColors() const;
void printAPI();
void printPools();
void printVersions();

View file

@ -23,11 +23,11 @@
*/
#include "base/io/log/Log.h"
#include "base/io/Watcher.h"
#include "base/kernel/interfaces/IConfigListener.h"
#include "common/config/ConfigLoader.h"
#include "common/config/ConfigWatcher.h"
#include "common/log/Log.h"
#include "core/ConfigCreator.h"

View file

@ -1,32 +0,0 @@
/* XMRig
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef XMRIG_LOG_LEGACY_H
#define XMRIG_LOG_LEGACY_H
#include "base/io/log/Log.h"
#endif /* XMRIG_LOG_LEGACY_H */

View file

@ -40,5 +40,6 @@
"safe": false,
"threads": null,
"user-agent": null,
"syslog": false,
"watch": true
}

View file

@ -27,6 +27,7 @@
#include <inttypes.h>
#include "base/io/log/Log.h"
#include "common/config/ConfigLoader.h"
#include "common/cpu/Cpu.h"
#include "core/Config.h"
@ -87,7 +88,7 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
doc.AddMember("autosave", isAutoSave(), allocator);
doc.AddMember("av", algoVariant(), allocator);
doc.AddMember("background", isBackground(), allocator);
doc.AddMember("colors", isColors(), allocator);
doc.AddMember("colors", Log::colors, allocator);
if (affinity() != -1L) {
snprintf(affinity_tmp, sizeof(affinity_tmp) - 1, "0x%" PRIX64, affinity());
@ -123,13 +124,9 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
doc.AddMember("threads", threadsCount(), allocator);
}
doc.AddMember("user-agent", userAgent() ? Value(StringRef(userAgent())).Move() : Value(kNullType).Move(), allocator);
# ifdef HAVE_SYSLOG_H
doc.AddMember("syslog", isSyslog(), allocator);
# endif
doc.AddMember("watch", m_watch, allocator);
doc.AddMember("user-agent", m_userAgent.toJSON(), allocator);
doc.AddMember("syslog", isSyslog(), allocator);
doc.AddMember("watch", m_watch, allocator);
}

View file

@ -50,6 +50,7 @@ R"===(
"cpu-affinity": null,
"cpu-priority": null,
"donate-level": 5,
"donate-over-proxy": 1,
"huge-pages": true,
"hw-aes": null,
"log-file": null,
@ -73,7 +74,8 @@ R"===(
"safe": false,
"threads": null,
"user-agent": null,
"watch": false
"syslog": false,
"watch": true
}
)===";
#endif

View file

@ -28,10 +28,10 @@
#include "base/io/log/backends/ConsoleLog.h"
#include "base/io/log/backends/FileLog.h"
#include "base/io/log/Log.h"
#include "common/config/ConfigLoader.h"
#include "common/cpu/Cpu.h"
#include "common/interfaces/IControllerListener.h"
#include "common/log/Log.h"
#include "common/Platform.h"
#include "core/Config.h"
#include "core/Controller.h"

View file

@ -32,11 +32,11 @@
#include "api/Api.h"
#include "base/io/log/Log.h"
#include "base/net/stratum/Client.h"
#include "base/net/stratum/SubmitResult.h"
#include "base/tools/Chrono.h"
#include "base/tools/Timer.h"
#include "common/log/Log.h"
#include "core/Config.h"
#include "core/Controller.h"
#include "net/Network.h"
@ -90,13 +90,12 @@ void xmrig::Network::onActive(IStrategy *strategy, Client *client)
m_state.setPool(client->host(), client->port(), client->ip());
const char *tlsVersion = client->tlsVersion();
LOG_INFO(isColors() ? WHITE_BOLD("use pool ") CYAN_BOLD("%s:%d ") GREEN_BOLD("%s") " \x1B[1;30m%s "
: "use pool %s:%d %s %s",
LOG_INFO(WHITE_BOLD("use pool ") CYAN_BOLD("%s:%d ") GREEN_BOLD("%s") " " BLACK_BOLD("%s"),
client->host(), client->port(), tlsVersion ? tlsVersion : "", client->ip());
const char *fingerprint = client->tlsFingerprint();
if (fingerprint != nullptr) {
LOG_INFO("%sfingerprint (SHA-256): \"%s\"", isColors() ? "\x1B[1;30m" : "", fingerprint);
LOG_INFO(BLACK_BOLD("fingerprint (SHA-256): \"%s\""), fingerprint);
}
}
@ -158,34 +157,24 @@ void xmrig::Network::onResultAccepted(IStrategy *, Client *, const SubmitResult
m_state.add(result, error);
if (error) {
LOG_INFO(isColors() ? "\x1B[1;31mrejected\x1B[0m (%" PRId64 "/%" PRId64 ") diff \x1B[1;37m%u\x1B[0m \x1B[31m\"%s\"\x1B[0m \x1B[1;30m(%" PRIu64 " ms)"
: "rejected (%" PRId64 "/%" PRId64 ") diff %u \"%s\" (%" PRIu64 " ms)",
LOG_INFO(RED_BOLD("rejected") " (%" PRId64 "/%" PRId64 ") diff " WHITE_BOLD("%u") " " RED("\"%s\"") " " BLACK_BOLD("(%" PRIu64 " ms)"),
m_state.accepted, m_state.rejected, result.diff, error, result.elapsed);
}
else {
LOG_INFO(isColors() ? "\x1B[1;32maccepted\x1B[0m (%" PRId64 "/%" PRId64 ") diff \x1B[1;37m%u\x1B[0m \x1B[1;30m(%" PRIu64 " ms)"
: "accepted (%" PRId64 "/%" PRId64 ") diff %u (%" PRIu64 " ms)",
LOG_INFO(GREEN_BOLD("accepted") " (%" PRId64 "/%" PRId64 ") diff " WHITE_BOLD("%u") " " BLACK_BOLD("(%" PRIu64 " ms)"),
m_state.accepted, m_state.rejected, result.diff, result.elapsed);
}
}
bool xmrig::Network::isColors() const
{
return Log::colors;
}
void xmrig::Network::setJob(Client *client, const Job &job, bool donate)
{
if (job.height()) {
LOG_INFO(isColors() ? MAGENTA_BOLD("new job") " from " WHITE_BOLD("%s:%d") " diff " WHITE_BOLD("%d") " algo " WHITE_BOLD("%s") " height " WHITE_BOLD("%" PRIu64)
: "new job from %s:%d diff %d algo %s height %" PRIu64,
LOG_INFO(MAGENTA_BOLD("new job") " from " WHITE_BOLD("%s:%d") " diff " WHITE_BOLD("%d") " algo " WHITE_BOLD("%s") " height " WHITE_BOLD("%" PRIu64),
client->host(), client->port(), job.diff(), job.algorithm().shortName(), job.height());
}
else {
LOG_INFO(isColors() ? MAGENTA_BOLD("new job") " from " WHITE_BOLD("%s:%d") " diff " WHITE_BOLD("%d") " algo " WHITE_BOLD("%s")
: "new job from %s:%d diff %d algo %s",
LOG_INFO(MAGENTA_BOLD("new job") " from " WHITE_BOLD("%s:%d") " diff " WHITE_BOLD("%d") " algo " WHITE_BOLD("%s"),
client->host(), client->port(), job.diff(), job.algorithm().shortName());
}

View file

@ -66,7 +66,6 @@ protected:
private:
constexpr static int kTickInterval = 1 * 1000;
bool isColors() const;
void setJob(Client *client, const Job &job, bool donate);
void tick();

View file

@ -25,8 +25,8 @@
#include <assert.h>
#include "base/io/log/Log.h"
#include "common/cpu/Cpu.h"
#include "common/log/Log.h"
#include "crypto/Asm.h"
#include "Mem.h"
#include "rapidjson/document.h"

View file

@ -30,8 +30,8 @@
#include <stdio.h>
#include "base/io/log/Log.h"
#include "base/tools/Handle.h"
#include "common/log/Log.h"
#include "core/Config.h"
#include "core/Controller.h"
#include "workers/Hashrate.h"
@ -163,8 +163,7 @@ void Hashrate::print() const
char num3[8] = { 0 };
char num4[8] = { 0 };
LOG_INFO(m_controller->config()->isColors() ? WHITE_BOLD("speed") " 10s/60s/15m " CYAN_BOLD("%s") CYAN(" %s %s ") CYAN_BOLD("H/s") " max " CYAN_BOLD("%s H/s")
: "speed 10s/60s/15m %s %s %s H/s max %s H/s",
LOG_INFO(WHITE_BOLD("speed") " 10s/60s/15m " CYAN_BOLD("%s") CYAN(" %s %s ") CYAN_BOLD("H/s") " max " CYAN_BOLD("%s H/s"),
format(calc(ShortInterval), num1, sizeof(num1)),
format(calc(MediumInterval), num2, sizeof(num2)),
format(calc(LargeInterval), num3, sizeof(num3)),

View file

@ -28,7 +28,6 @@
#include "crypto/CryptoNight_test.h"
#include "common/log/Log.h"
#include "workers/CpuThread.h"
#include "workers/MultiWorker.h"
#include "workers/Workers.h"

View file

@ -28,8 +28,8 @@
#include "api/Api.h"
#include "base/io/log/Log.h"
#include "base/tools/Handle.h"
#include "common/log/Log.h"
#include "core/Config.h"
#include "core/Controller.h"
#include "crypto/CryptoNight_constants.h"
@ -99,12 +99,11 @@ void Workers::printHashrate(bool detail)
}
if (detail) {
const bool isColors = m_controller->config()->isColors();
char num1[8] = { 0 };
char num2[8] = { 0 };
char num3[8] = { 0 };
xmrig::Log::print("%s| THREAD | AFFINITY | 10s H/s | 60s H/s | 15m H/s |", isColors ? "\x1B[1;37m" : "");
xmrig::Log::print(WHITE_BOLD_S "| THREAD | AFFINITY | 10s H/s | 60s H/s | 15m H/s |");
size_t i = 0;
for (const xmrig::IThread *thread : m_controller->config()->threads()) {
@ -178,7 +177,6 @@ void Workers::start(xmrig::Controller *controller)
const std::vector<xmrig::IThread *> &threads = controller->config()->threads();
m_status.algo = controller->config()->algorithm().algo();
m_status.colors = controller->config()->isColors();
m_status.threads = threads.size();
for (const xmrig::IThread *thread : threads) {
@ -302,7 +300,7 @@ void Workers::onReady(void *arg)
}
void Workers::onResult(uv_async_t *handle)
void Workers::onResult(uv_async_t *)
{
std::list<xmrig::JobResult> results;
@ -321,7 +319,7 @@ void Workers::onResult(uv_async_t *handle)
}
void Workers::onTick(uv_timer_t *handle)
void Workers::onTick(uv_timer_t *)
{
for (ThreadHandle *handle : m_workers) {
if (!handle->worker()) {
@ -350,16 +348,10 @@ void Workers::start(IWorker *worker)
const double percent = (double) m_status.hugePages / m_status.pages * 100.0;
const size_t memory = m_status.ways * xmrig::cn_select_memory(m_status.algo) / 1024;
if (m_status.colors) {
LOG_INFO(GREEN_BOLD("READY (CPU)") " threads " CYAN_BOLD("%zu(%zu)") " huge pages %s%zu/%zu %1.0f%%\x1B[0m memory " CYAN_BOLD("%zu KB") "",
m_status.threads, m_status.ways,
(m_status.hugePages == m_status.pages ? "\x1B[1;32m" : (m_status.hugePages == 0 ? "\x1B[1;31m" : "\x1B[1;33m")),
m_status.hugePages, m_status.pages, percent, memory);
}
else {
LOG_INFO("READY (CPU) threads %zu(%zu) huge pages %zu/%zu %1.0f%% memory %zu KB",
m_status.threads, m_status.ways, m_status.hugePages, m_status.pages, percent, memory);
}
LOG_INFO(GREEN_BOLD("READY (CPU)") " threads " CYAN_BOLD("%zu(%zu)") " huge pages %s%zu/%zu %1.0f%%\x1B[0m memory " CYAN_BOLD("%zu KB") "",
m_status.threads, m_status.ways,
(m_status.hugePages == m_status.pages ? GREEN_BOLD_S : (m_status.hugePages == 0 ? RED_BOLD_S : YELLOW_BOLD_S)),
m_status.hugePages, m_status.pages, percent, memory);
}
uv_mutex_unlock(&m_mutex);

View file

@ -82,7 +82,6 @@ private:
{
public:
inline LaunchStatus() :
colors(true),
hugePages(0),
pages(0),
started(0),
@ -91,7 +90,6 @@ private:
algo(xmrig::CRYPTONIGHT)
{}
bool colors;
size_t hugePages;
size_t pages;
size_t started;