mirror of https://github.com/oxen-io/oxen-mq.git
Made `log()` callable publicly
This allows use of some free functions within lokimq that can still log (assuming they have a LokiMQ reference).
This commit is contained in:
parent
29380922bf
commit
44b91534c2
|
@ -204,7 +204,7 @@ void LokiMQ::process_zap_requests() {
|
|||
else
|
||||
o << v;
|
||||
}
|
||||
log_(LogLevel::trace, __FILE__, __LINE__, o.str());
|
||||
log(LogLevel::trace, __FILE__, __LINE__, o.str());
|
||||
} else
|
||||
#endif
|
||||
LMQ_LOG(debug, "Processing ZAP authentication request");
|
||||
|
|
|
@ -4,12 +4,11 @@
|
|||
// Inside some method:
|
||||
// LMQ_LOG(warn, "bad ", 42, " stuff");
|
||||
//
|
||||
// (The "this->" is here to work around gcc 5 bugginess when called in a `this`-capturing lambda.)
|
||||
#define LMQ_LOG(level, ...) this->log_(LogLevel::level, __FILE__, __LINE__, __VA_ARGS__)
|
||||
#define LMQ_LOG(level, ...) log(LogLevel::level, __FILE__, __LINE__, __VA_ARGS__)
|
||||
|
||||
#ifndef NDEBUG
|
||||
// Same as LMQ_LOG(trace, ...) when not doing a release build; nothing under a release build.
|
||||
# define LMQ_TRACE(...) this->log_(LogLevel::trace, __FILE__, __LINE__, __VA_ARGS__)
|
||||
# define LMQ_TRACE(...) log(LogLevel::trace, __FILE__, __LINE__, __VA_ARGS__)
|
||||
#else
|
||||
# define LMQ_TRACE(...)
|
||||
#endif
|
||||
|
|
|
@ -268,6 +268,10 @@ public:
|
|||
/// to direct very simple batch completion jobs to be executed directly in the proxy thread.
|
||||
inline static const TaggedThread run_in_proxy{"_proxy", -1};
|
||||
|
||||
/// Writes a message to the logging system; intended mostly for internal use.
|
||||
template <typename... T>
|
||||
void log(LogLevel lvl, const char* filename, int line, const T&... stuff);
|
||||
|
||||
private:
|
||||
|
||||
/// The lookup function that tells us where to connect to a peer, or empty if not found.
|
||||
|
@ -280,10 +284,6 @@ private:
|
|||
/// The callback to call with log messages
|
||||
Logger logger;
|
||||
|
||||
/// Logging implementation
|
||||
template <typename... T>
|
||||
void log_(LogLevel lvl, const char* filename, int line, const T&... stuff);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// NB: The following are all the domain of the proxy thread (once it is started)!
|
||||
|
||||
|
@ -1433,7 +1433,7 @@ inline std::string_view trim_log_filename(std::string_view local_file) {
|
|||
}
|
||||
|
||||
template <typename... T>
|
||||
void LokiMQ::log_(LogLevel lvl, const char* file, int line, const T&... stuff) {
|
||||
void LokiMQ::log(LogLevel lvl, const char* file, int line, const T&... stuff) {
|
||||
if (log_level() < lvl)
|
||||
return;
|
||||
|
||||
|
|
Loading…
Reference in New Issue