mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-12-23 14:48:52 +00:00
2899379791
Daemons intended for public use can be set up to require payment in the form of hashes in exchange for RPC service. This enables public daemons to receive payment for their work over a large number of calls. This system behaves similarly to a pool, so payment takes the form of valid blocks every so often, yielding a large one off payment, rather than constant micropayments. This system can also be used by third parties as a "paywall" layer, where users of a service can pay for use by mining Monero to the service provider's address. An example of this for web site access is Primo, a Monero mining based website "paywall": https://github.com/selene-kovri/primo This has some advantages: - incentive to run a node providing RPC services, thereby promoting the availability of third party nodes for those who can't run their own - incentive to run your own node instead of using a third party's, thereby promoting decentralization - decentralized: payment is done between a client and server, with no third party needed - private: since the system is "pay as you go", you don't need to identify yourself to claim a long lived balance - no payment occurs on the blockchain, so there is no extra transactional load - one may mine with a beefy server, and use those credits from a phone, by reusing the client ID (at the cost of some privacy) - no barrier to entry: anyone may run a RPC node, and your expected revenue depends on how much work you do - Sybil resistant: if you run 1000 idle RPC nodes, you don't magically get more revenue - no large credit balance maintained on servers, so they have no incentive to exit scam - you can use any/many node(s), since there's little cost in switching servers - market based prices: competition between servers to lower costs - incentive for a distributed third party node system: if some public nodes are overused/slow, traffic can move to others - increases network security - helps counteract mining pools' share of the network hash rate - zero incentive for a payer to "double spend" since a reorg does not give any money back to the miner And some disadvantages: - low power clients will have difficulty mining (but one can optionally mine in advance and/or with a faster machine) - payment is "random", so a server might go a long time without a block before getting one - a public node's overall expected payment may be small Public nodes are expected to compete to find a suitable level for cost of service. The daemon can be set up this way to require payment for RPC services: monerod --rpc-payment-address 4xxxxxx \ --rpc-payment-credits 250 --rpc-payment-difficulty 1000 These values are an example only. The --rpc-payment-difficulty switch selects how hard each "share" should be, similar to a mining pool. The higher the difficulty, the fewer shares a client will find. The --rpc-payment-credits switch selects how many credits are awarded for each share a client finds. Considering both options, clients will be awarded credits/difficulty credits for every hash they calculate. For example, in the command line above, 0.25 credits per hash. A client mining at 100 H/s will therefore get an average of 25 credits per second. For reference, in the current implementation, a credit is enough to sync 20 blocks, so a 100 H/s client that's just starting to use Monero and uses this daemon will be able to sync 500 blocks per second. The wallet can be set to automatically mine if connected to a daemon which requires payment for RPC usage. It will try to keep a balance of 50000 credits, stopping mining when it's at this level, and starting again as credits are spent. With the example above, a new client will mine this much credits in about half an hour, and this target is enough to sync 500000 blocks (currently about a third of the monero blockchain). There are three new settings in the wallet: - credits-target: this is the amount of credits a wallet will try to reach before stopping mining. The default of 0 means 50000 credits. - auto-mine-for-rpc-payment-threshold: this controls the minimum credit rate which the wallet considers worth mining for. If the daemon credits less than this ratio, the wallet will consider mining to be not worth it. In the example above, the rate is 0.25 - persistent-rpc-client-id: if set, this allows the wallet to reuse a client id across runs. This means a public node can tell a wallet that's connecting is the same as one that connected previously, but allows a wallet to keep their credit balance from one run to the other. Since the wallet only mines to keep a small credit balance, this is not normally worth doing. However, someone may want to mine on a fast server, and use that credit balance on a low power device such as a phone. If left unset, a new client ID is generated at each wallet start, for privacy reasons. To mine and use a credit balance on two different devices, you can use the --rpc-client-secret-key switch. A wallet's client secret key can be found using the new rpc_payments command in the wallet. Note: anyone knowing your RPC client secret key is able to use your credit balance. The wallet has a few new commands too: - start_mining_for_rpc: start mining to acquire more credits, regardless of the auto mining settings - stop_mining_for_rpc: stop mining to acquire more credits - rpc_payments: display information about current credits with the currently selected daemon The node has an extra command: - rpc_payments: display information about clients and their balances The node will forget about any balance for clients which have been inactive for 6 months. Balances carry over on node restart.
526 lines
15 KiB
C++
526 lines
15 KiB
C++
// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
|
|
// All rights reserved.
|
|
//
|
|
// Redistribution and use in source and binary forms, with or without
|
|
// modification, are permitted provided that the following conditions are met:
|
|
// * Redistributions of source code must retain the above copyright
|
|
// notice, this list of conditions and the following disclaimer.
|
|
// * Redistributions in binary form must reproduce the above copyright
|
|
// notice, this list of conditions and the following disclaimer in the
|
|
// documentation and/or other materials provided with the distribution.
|
|
// * Neither the name of the Andrey N. Sabelnikov nor the
|
|
// names of its contributors may be used to endorse or promote products
|
|
// derived from this software without specific prior written permission.
|
|
//
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER BE LIABLE FOR ANY
|
|
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
//
|
|
|
|
|
|
#ifndef _MLOG_H_
|
|
#define _MLOG_H_
|
|
|
|
#ifdef _WIN32
|
|
#include <windows.h>
|
|
#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING
|
|
#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
|
|
#endif
|
|
#endif
|
|
|
|
#include <time.h>
|
|
#include <atomic>
|
|
#include <boost/filesystem.hpp>
|
|
#include <boost/algorithm/string.hpp>
|
|
#include "string_tools.h"
|
|
#include "misc_os_dependent.h"
|
|
#include "misc_log_ex.h"
|
|
|
|
#undef MONERO_DEFAULT_LOG_CATEGORY
|
|
#define MONERO_DEFAULT_LOG_CATEGORY "logging"
|
|
|
|
#define MLOG_BASE_FORMAT "%datetime{%Y-%M-%d %H:%m:%s.%g}\t%thread\t%level\t%logger\t%loc\t%msg"
|
|
|
|
#define MLOG_LOG(x) CINFO(el::base::Writer,el::base::DispatchAction::FileOnlyLog,MONERO_DEFAULT_LOG_CATEGORY) << x
|
|
|
|
using namespace epee;
|
|
|
|
static std::string generate_log_filename(const char *base)
|
|
{
|
|
std::string filename(base);
|
|
static unsigned int fallback_counter = 0;
|
|
char tmp[200];
|
|
struct tm tm;
|
|
time_t now = time(NULL);
|
|
if (!epee::misc_utils::get_gmt_time(now, tm))
|
|
snprintf(tmp, sizeof(tmp), "part-%u", ++fallback_counter);
|
|
else
|
|
strftime(tmp, sizeof(tmp), "%Y-%m-%d-%H-%M-%S", &tm);
|
|
tmp[sizeof(tmp) - 1] = 0;
|
|
filename += "-";
|
|
filename += tmp;
|
|
return filename;
|
|
}
|
|
|
|
std::string mlog_get_default_log_path(const char *default_filename)
|
|
{
|
|
std::string process_name = epee::string_tools::get_current_module_name();
|
|
std::string default_log_folder = epee::string_tools::get_current_module_folder();
|
|
std::string default_log_file = process_name;
|
|
std::string::size_type a = default_log_file.rfind('.');
|
|
if ( a != std::string::npos )
|
|
default_log_file.erase( a, default_log_file.size());
|
|
if ( ! default_log_file.empty() )
|
|
default_log_file += ".log";
|
|
else
|
|
default_log_file = default_filename;
|
|
|
|
return (boost::filesystem::path(default_log_folder) / boost::filesystem::path(default_log_file)).string();
|
|
}
|
|
|
|
static void mlog_set_common_prefix()
|
|
{
|
|
static const char * const expected_filename = "contrib/epee/src/mlog.cpp";
|
|
const char *path = __FILE__, *expected_ptr = strstr(path, expected_filename);
|
|
if (!expected_ptr)
|
|
return;
|
|
el::Loggers::setFilenameCommonPrefix(std::string(path, expected_ptr - path));
|
|
}
|
|
|
|
static const char *get_default_categories(int level)
|
|
{
|
|
const char *categories = "";
|
|
switch (level)
|
|
{
|
|
case 0:
|
|
categories = "*:WARNING,net:FATAL,net.http:FATAL,net.ssl:FATAL,net.p2p:FATAL,net.cn:FATAL,global:INFO,verify:FATAL,serialization:FATAL,daemon.rpc.payment:ERROR,stacktrace:INFO,logging:INFO,msgwriter:INFO";
|
|
break;
|
|
case 1:
|
|
categories = "*:INFO,global:INFO,stacktrace:INFO,logging:INFO,msgwriter:INFO,perf.*:DEBUG";
|
|
break;
|
|
case 2:
|
|
categories = "*:DEBUG";
|
|
break;
|
|
case 3:
|
|
categories = "*:TRACE,*.dump:DEBUG";
|
|
break;
|
|
case 4:
|
|
categories = "*:TRACE";
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return categories;
|
|
}
|
|
|
|
#ifdef WIN32
|
|
bool EnableVTMode()
|
|
{
|
|
// Set output mode to handle virtual terminal sequences
|
|
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
if (hOut == INVALID_HANDLE_VALUE)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
DWORD dwMode = 0;
|
|
if (!GetConsoleMode(hOut, &dwMode))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
|
|
if (!SetConsoleMode(hOut, dwMode))
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
#endif
|
|
|
|
void mlog_configure(const std::string &filename_base, bool console, const std::size_t max_log_file_size, const std::size_t max_log_files)
|
|
{
|
|
el::Configurations c;
|
|
c.setGlobally(el::ConfigurationType::Filename, filename_base);
|
|
c.setGlobally(el::ConfigurationType::ToFile, "true");
|
|
const char *log_format = getenv("MONERO_LOG_FORMAT");
|
|
if (!log_format)
|
|
log_format = MLOG_BASE_FORMAT;
|
|
c.setGlobally(el::ConfigurationType::Format, log_format);
|
|
c.setGlobally(el::ConfigurationType::ToStandardOutput, console ? "true" : "false");
|
|
c.setGlobally(el::ConfigurationType::MaxLogFileSize, std::to_string(max_log_file_size));
|
|
el::Loggers::setDefaultConfigurations(c, true);
|
|
|
|
el::Loggers::addFlag(el::LoggingFlag::HierarchicalLogging);
|
|
el::Loggers::addFlag(el::LoggingFlag::CreateLoggerAutomatically);
|
|
el::Loggers::addFlag(el::LoggingFlag::DisableApplicationAbortOnFatalLog);
|
|
el::Loggers::addFlag(el::LoggingFlag::ColoredTerminalOutput);
|
|
el::Loggers::addFlag(el::LoggingFlag::StrictLogFileSizeCheck);
|
|
el::Helpers::installPreRollOutCallback([filename_base, max_log_files](const char *name, size_t){
|
|
std::string rname = generate_log_filename(filename_base.c_str());
|
|
int ret = rename(name, rname.c_str());
|
|
if (ret < 0)
|
|
{
|
|
// can't log a failure, but don't do the file removal below
|
|
return;
|
|
}
|
|
if (max_log_files != 0)
|
|
{
|
|
std::vector<boost::filesystem::path> found_files;
|
|
const boost::filesystem::directory_iterator end_itr;
|
|
const boost::filesystem::path filename_base_path(filename_base);
|
|
const boost::filesystem::path parent_path = filename_base_path.has_parent_path() ? filename_base_path.parent_path() : ".";
|
|
for (boost::filesystem::directory_iterator iter(parent_path); iter != end_itr; ++iter)
|
|
{
|
|
const std::string filename = iter->path().string();
|
|
if (filename.size() >= filename_base.size() && std::memcmp(filename.data(), filename_base.data(), filename_base.size()) == 0)
|
|
{
|
|
found_files.push_back(iter->path());
|
|
}
|
|
}
|
|
if (found_files.size() >= max_log_files)
|
|
{
|
|
std::sort(found_files.begin(), found_files.end(), [](const boost::filesystem::path &a, const boost::filesystem::path &b) {
|
|
boost::system::error_code ec;
|
|
std::time_t ta = boost::filesystem::last_write_time(boost::filesystem::path(a), ec);
|
|
if (ec)
|
|
{
|
|
MERROR("Failed to get timestamp from " << a << ": " << ec);
|
|
ta = std::time(nullptr);
|
|
}
|
|
std::time_t tb = boost::filesystem::last_write_time(boost::filesystem::path(b), ec);
|
|
if (ec)
|
|
{
|
|
MERROR("Failed to get timestamp from " << b << ": " << ec);
|
|
tb = std::time(nullptr);
|
|
}
|
|
static_assert(std::is_integral<time_t>(), "bad time_t");
|
|
return ta < tb;
|
|
});
|
|
for (size_t i = 0; i <= found_files.size() - max_log_files; ++i)
|
|
{
|
|
try
|
|
{
|
|
boost::system::error_code ec;
|
|
boost::filesystem::remove(found_files[i], ec);
|
|
if (ec)
|
|
{
|
|
MERROR("Failed to remove " << found_files[i] << ": " << ec);
|
|
}
|
|
}
|
|
catch (const std::exception &e)
|
|
{
|
|
MERROR("Failed to remove " << found_files[i] << ": " << e.what());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
mlog_set_common_prefix();
|
|
const char *monero_log = getenv("MONERO_LOGS");
|
|
if (!monero_log)
|
|
{
|
|
monero_log = get_default_categories(0);
|
|
}
|
|
mlog_set_log(monero_log);
|
|
#ifdef WIN32
|
|
EnableVTMode();
|
|
#endif
|
|
}
|
|
|
|
void mlog_set_categories(const char *categories)
|
|
{
|
|
std::string new_categories;
|
|
if (*categories)
|
|
{
|
|
if (*categories == '+')
|
|
{
|
|
++categories;
|
|
new_categories = mlog_get_categories();
|
|
if (*categories)
|
|
{
|
|
if (!new_categories.empty())
|
|
new_categories += ",";
|
|
new_categories += categories;
|
|
}
|
|
}
|
|
else if (*categories == '-')
|
|
{
|
|
++categories;
|
|
new_categories = mlog_get_categories();
|
|
std::vector<std::string> single_categories;
|
|
boost::split(single_categories, categories, boost::is_any_of(","), boost::token_compress_on);
|
|
for (const std::string &s: single_categories)
|
|
{
|
|
size_t pos = new_categories.find(s);
|
|
if (pos != std::string::npos)
|
|
new_categories = new_categories.erase(pos, s.size());
|
|
}
|
|
}
|
|
else
|
|
{
|
|
new_categories = categories;
|
|
}
|
|
}
|
|
el::Loggers::setCategories(new_categories.c_str(), true);
|
|
MLOG_LOG("New log categories: " << el::Loggers::getCategories());
|
|
}
|
|
|
|
std::string mlog_get_categories()
|
|
{
|
|
return el::Loggers::getCategories();
|
|
}
|
|
|
|
// maps epee style log level to new logging system
|
|
void mlog_set_log_level(int level)
|
|
{
|
|
const char *categories = get_default_categories(level);
|
|
mlog_set_categories(categories);
|
|
}
|
|
|
|
void mlog_set_log(const char *log)
|
|
{
|
|
long level;
|
|
char *ptr = NULL;
|
|
|
|
if (!*log)
|
|
{
|
|
mlog_set_categories(log);
|
|
return;
|
|
}
|
|
level = strtol(log, &ptr, 10);
|
|
if (ptr && *ptr)
|
|
{
|
|
// we can have a default level, eg, 2,foo:ERROR
|
|
if (*ptr == ',') {
|
|
std::string new_categories = std::string(get_default_categories(level)) + ptr;
|
|
mlog_set_categories(new_categories.c_str());
|
|
}
|
|
else {
|
|
mlog_set_categories(log);
|
|
}
|
|
}
|
|
else if (level >= 0 && level <= 4)
|
|
{
|
|
mlog_set_log_level(level);
|
|
}
|
|
else
|
|
{
|
|
MERROR("Invalid numerical log level: " << log);
|
|
}
|
|
}
|
|
|
|
namespace epee
|
|
{
|
|
|
|
bool is_stdout_a_tty()
|
|
{
|
|
static std::atomic<bool> initialized(false);
|
|
static std::atomic<bool> is_a_tty(false);
|
|
|
|
if (!initialized.load(std::memory_order_acquire))
|
|
{
|
|
#if defined(WIN32)
|
|
is_a_tty.store(0 != _isatty(_fileno(stdout)), std::memory_order_relaxed);
|
|
#else
|
|
is_a_tty.store(0 != isatty(fileno(stdout)), std::memory_order_relaxed);
|
|
#endif
|
|
initialized.store(true, std::memory_order_release);
|
|
}
|
|
|
|
return is_a_tty.load(std::memory_order_relaxed);
|
|
}
|
|
|
|
void set_console_color(int color, bool bright)
|
|
{
|
|
if (!is_stdout_a_tty())
|
|
return;
|
|
|
|
switch(color)
|
|
{
|
|
case console_color_default:
|
|
{
|
|
#ifdef WIN32
|
|
HANDLE h_stdout = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
SetConsoleTextAttribute(h_stdout, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE| (bright ? FOREGROUND_INTENSITY:0));
|
|
#else
|
|
if(bright)
|
|
std::cout << "\033[1;37m";
|
|
else
|
|
std::cout << "\033[0m";
|
|
#endif
|
|
}
|
|
break;
|
|
case console_color_white:
|
|
{
|
|
#ifdef WIN32
|
|
HANDLE h_stdout = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
SetConsoleTextAttribute(h_stdout, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | (bright ? FOREGROUND_INTENSITY:0));
|
|
#else
|
|
if(bright)
|
|
std::cout << "\033[1;37m";
|
|
else
|
|
std::cout << "\033[0;37m";
|
|
#endif
|
|
}
|
|
break;
|
|
case console_color_red:
|
|
{
|
|
#ifdef WIN32
|
|
HANDLE h_stdout = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
SetConsoleTextAttribute(h_stdout, FOREGROUND_RED | (bright ? FOREGROUND_INTENSITY:0));
|
|
#else
|
|
if(bright)
|
|
std::cout << "\033[1;31m";
|
|
else
|
|
std::cout << "\033[0;31m";
|
|
#endif
|
|
}
|
|
break;
|
|
case console_color_green:
|
|
{
|
|
#ifdef WIN32
|
|
HANDLE h_stdout = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
SetConsoleTextAttribute(h_stdout, FOREGROUND_GREEN | (bright ? FOREGROUND_INTENSITY:0));
|
|
#else
|
|
if(bright)
|
|
std::cout << "\033[1;32m";
|
|
else
|
|
std::cout << "\033[0;32m";
|
|
#endif
|
|
}
|
|
break;
|
|
|
|
case console_color_blue:
|
|
{
|
|
#ifdef WIN32
|
|
HANDLE h_stdout = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
SetConsoleTextAttribute(h_stdout, FOREGROUND_BLUE | FOREGROUND_INTENSITY);//(bright ? FOREGROUND_INTENSITY:0));
|
|
#else
|
|
if(bright)
|
|
std::cout << "\033[1;34m";
|
|
else
|
|
std::cout << "\033[0;34m";
|
|
#endif
|
|
}
|
|
break;
|
|
|
|
case console_color_cyan:
|
|
{
|
|
#ifdef WIN32
|
|
HANDLE h_stdout = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
SetConsoleTextAttribute(h_stdout, FOREGROUND_GREEN | FOREGROUND_BLUE | (bright ? FOREGROUND_INTENSITY:0));
|
|
#else
|
|
if(bright)
|
|
std::cout << "\033[1;36m";
|
|
else
|
|
std::cout << "\033[0;36m";
|
|
#endif
|
|
}
|
|
break;
|
|
|
|
case console_color_magenta:
|
|
{
|
|
#ifdef WIN32
|
|
HANDLE h_stdout = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
SetConsoleTextAttribute(h_stdout, FOREGROUND_BLUE | FOREGROUND_RED | (bright ? FOREGROUND_INTENSITY:0));
|
|
#else
|
|
if(bright)
|
|
std::cout << "\033[1;35m";
|
|
else
|
|
std::cout << "\033[0;35m";
|
|
#endif
|
|
}
|
|
break;
|
|
|
|
case console_color_yellow:
|
|
{
|
|
#ifdef WIN32
|
|
HANDLE h_stdout = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
SetConsoleTextAttribute(h_stdout, FOREGROUND_RED | FOREGROUND_GREEN | (bright ? FOREGROUND_INTENSITY:0));
|
|
#else
|
|
if(bright)
|
|
std::cout << "\033[1;33m";
|
|
else
|
|
std::cout << "\033[0;33m";
|
|
#endif
|
|
}
|
|
break;
|
|
|
|
}
|
|
}
|
|
|
|
void reset_console_color() {
|
|
if (!is_stdout_a_tty())
|
|
return;
|
|
|
|
#ifdef WIN32
|
|
HANDLE h_stdout = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
SetConsoleTextAttribute(h_stdout, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
|
|
#else
|
|
std::cout << "\033[0m";
|
|
std::cout.flush();
|
|
#endif
|
|
}
|
|
|
|
}
|
|
|
|
static bool mlog(el::Level level, const char *category, const char *format, va_list ap) noexcept
|
|
{
|
|
int size = 0;
|
|
char *p = NULL;
|
|
va_list apc;
|
|
bool ret = true;
|
|
|
|
/* Determine required size */
|
|
va_copy(apc, ap);
|
|
size = vsnprintf(p, size, format, apc);
|
|
va_end(apc);
|
|
if (size < 0)
|
|
return false;
|
|
|
|
size++; /* For '\0' */
|
|
p = (char*)malloc(size);
|
|
if (p == NULL)
|
|
return false;
|
|
|
|
size = vsnprintf(p, size, format, ap);
|
|
if (size < 0)
|
|
{
|
|
free(p);
|
|
return false;
|
|
}
|
|
|
|
try
|
|
{
|
|
MCLOG(level, category, el::Color::Default, p);
|
|
}
|
|
catch(...)
|
|
{
|
|
ret = false;
|
|
}
|
|
free(p);
|
|
|
|
return ret;
|
|
}
|
|
|
|
#define DEFLOG(fun,lev) \
|
|
bool m##fun(const char *category, const char *fmt, ...) { va_list ap; va_start(ap, fmt); bool ret = mlog(el::Level::lev, category, fmt, ap); va_end(ap); return ret; }
|
|
|
|
DEFLOG(error, Error)
|
|
DEFLOG(warning, Warning)
|
|
DEFLOG(info, Info)
|
|
DEFLOG(debug, Debug)
|
|
DEFLOG(trace, Trace)
|
|
|
|
#undef DEFLOG
|
|
|
|
#endif //_MLOG_H_
|