From 1f7e635b04aef8477379ebd990dcdb862836a5a1 Mon Sep 17 00:00:00 2001 From: XMRig Date: Tue, 26 Mar 2024 21:46:18 +0700 Subject: [PATCH] Use internal logger for error message. --- src/base/api/Api.cpp | 13 +++++++------ src/base/api/Api.h | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/base/api/Api.cpp b/src/base/api/Api.cpp index e0907a84a..77f8e4aa0 100644 --- a/src/base/api/Api.cpp +++ b/src/base/api/Api.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2023 SChernykh - * Copyright (c) 2016-2023 XMRig , + * Copyright (c) 2018-2024 SChernykh + * Copyright (c) 2016-2024 XMRig , * * 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 @@ -25,6 +25,8 @@ #include "base/crypto/keccak.h" #include "base/io/Env.h" #include "base/io/json/Json.h" +#include "base/io/log/Log.h" +#include "base/io/log/Tags.h" #include "base/kernel/Base.h" #include "base/tools/Chrono.h" #include "base/tools/Cvt.h" @@ -39,7 +41,6 @@ #include -#include namespace xmrig { @@ -81,8 +82,7 @@ static rapidjson::Value getResources(rapidjson::Document &doc) xmrig::Api::Api(Base *base) : m_base(base), - m_timestamp(Chrono::currentMSecsSinceEpoch()), - m_httpd(nullptr) + m_timestamp(Chrono::currentMSecsSinceEpoch()) { base->addListener(this); @@ -118,7 +118,8 @@ void xmrig::Api::start() if (!m_httpd) { m_httpd = new Httpd(m_base); if (!m_httpd->start()) { - std::cerr << "HTTP server failed to start." << std::endl; + LOG_ERR("%s " RED_BOLD("HTTP API server failed to start."), Tags::network()); + delete m_httpd; // Properly handle failure to start m_httpd = nullptr; } diff --git a/src/base/api/Api.h b/src/base/api/Api.h index 7c686ff40..f3ad04c10 100644 --- a/src/base/api/Api.h +++ b/src/base/api/Api.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2023 SChernykh - * Copyright (c) 2016-2023 XMRig , + * Copyright (c) 2018-2024 SChernykh + * Copyright (c) 2016-2024 XMRig , * * 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