mirror of https://github.com/oxen-io/oxen-mq.git
Allow log level to be specified in constructor
It can still be set using `lmq.log_level(...)`, but this can be slightly more convenient -- and without this log messages in the constructor are completely useless.
This commit is contained in:
parent
b66f653708
commit
bd196d08b8
|
@ -203,9 +203,10 @@ LokiMQ::LokiMQ(
|
|||
std::string privkey_,
|
||||
bool service_node,
|
||||
SNRemoteAddress lookup,
|
||||
Logger logger)
|
||||
Logger logger,
|
||||
LogLevel level)
|
||||
: object_id{next_id++}, pubkey{std::move(pubkey_)}, privkey{std::move(privkey_)}, local_service_node{service_node},
|
||||
sn_lookup{std::move(lookup)}, logger{std::move(logger)}
|
||||
sn_lookup{std::move(lookup)}, log_lvl{level}, logger{std::move(logger)}
|
||||
{
|
||||
|
||||
LMQ_TRACE("Constructing listening LokiMQ, id=", object_id, ", this=", this);
|
||||
|
|
|
@ -627,20 +627,26 @@ public:
|
|||
*
|
||||
* @param log a function or callable object that writes a log message. If omitted then all log
|
||||
* messages are suppressed.
|
||||
*
|
||||
* @param level the initial log level; defaults to warn. The log level can be changed later by
|
||||
* calling log_level(...).
|
||||
*/
|
||||
LokiMQ( std::string pubkey,
|
||||
std::string privkey,
|
||||
bool service_node,
|
||||
SNRemoteAddress sn_lookup,
|
||||
Logger logger = [](LogLevel, const char*, int, std::string) { });
|
||||
Logger logger = [](LogLevel, const char*, int, std::string) { },
|
||||
LogLevel level = LogLevel::warn);
|
||||
|
||||
/**
|
||||
* Simplified LokiMQ constructor for a simple listener without any SN connection/authentication
|
||||
* capabilities. This treats all remotes as "basic", non-service node connections for command
|
||||
* authentication purposes.
|
||||
* Simplified LokiMQ constructor for a non-listening client or simple listener without any
|
||||
* outgoing SN connection lookup capabilities. The LokiMQ object will not be able to establish
|
||||
* new connections (including reconnections) to service nodes by pubkey.
|
||||
*/
|
||||
explicit LokiMQ(Logger logger = [](LogLevel, const char*, int, std::string) { })
|
||||
: LokiMQ("", "", false, [](auto) { return ""s; /*no peer lookups*/ }, std::move(logger)) {}
|
||||
explicit LokiMQ(
|
||||
Logger logger = [](LogLevel, const char*, int, std::string) { },
|
||||
LogLevel level = LogLevel::warn)
|
||||
: LokiMQ("", "", false, [](auto) { return ""s; /*no peer lookups*/ }, std::move(logger), level) {}
|
||||
|
||||
/**
|
||||
* Destructor; instructs the proxy to quit. The proxy tells all workers to quit, waits for them
|
||||
|
|
Loading…
Reference in New Issue