New log support.
This commit is contained in:
parent
17e9e036f1
commit
f43929db98
26 changed files with 96 additions and 198 deletions
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue