#pragma once // Header for making actual log statements such as llarp::log::Info and so on work. #include #include #include #include #include #include "oxen/log/internal.hpp" namespace llarp { namespace log = oxen::log; } // Not ready to pollute these deprecation warnings everywhere yet #if 0 #define LOKINET_LOG_DEPRECATED(Meth) \ [[deprecated("Use formatted log::" #Meth "(cat, fmt, args...) instead")]] #else #define LOKINET_LOG_DEPRECATED(Meth) #endif // Deprecated loggers (in the top-level llarp namespace): namespace llarp { inline std::shared_ptr logRingBuffer = nullptr; namespace log_detail { inline log::CategoryLogger legacy_logger = log::Cat(""); template struct concat_args_fmt_impl; template struct concat_args_fmt_impl> { constexpr static std::array format{(I % 2 == 0 ? '{' : '}')...}; }; template constexpr std::string_view concat_args_fmt() { return std::string_view{ concat_args_fmt_impl>::format.data(), 2 * N}; } } // namespace log_detail template struct LOKINET_LOG_DEPRECATED(Trace) LogTrace : log::trace { LogTrace( T&&... args, const log::slns::source_location& location = log::slns::source_location::current()) : log::trace::trace{ log_detail::legacy_logger, log_detail::concat_args_fmt(), std::forward(args)..., location} {} }; template struct LOKINET_LOG_DEPRECATED(Debug) LogDebug : log::debug { LogDebug( T&&... args, const log::slns::source_location& location = log::slns::source_location::current()) : log::debug::debug{ log_detail::legacy_logger, log_detail::concat_args_fmt(), std::forward(args)..., location} {} }; template struct LOKINET_LOG_DEPRECATED(Info) LogInfo : log::info { LogInfo( T&&... args, const log::slns::source_location& location = log::slns::source_location::current()) : log::info::info{ log_detail::legacy_logger, log_detail::concat_args_fmt(), std::forward(args)..., location} {} }; template struct LOKINET_LOG_DEPRECATED(Warning) LogWarn : log::warning { LogWarn( T&&... args, const log::slns::source_location& location = log::slns::source_location::current()) : log::warning::warning{ log_detail::legacy_logger, log_detail::concat_args_fmt(), std::forward(args)..., location} {} }; template struct LOKINET_LOG_DEPRECATED(Error) LogError : log::error { LogError( T&&... args, const log::slns::source_location& location = log::slns::source_location::current()) : log::error::error{ log_detail::legacy_logger, log_detail::concat_args_fmt(), std::forward(args)..., location} {} }; template LogTrace(T&&...) -> LogTrace; template LogDebug(T&&...) -> LogDebug; template LogInfo(T&&...) -> LogInfo; template LogWarn(T&&...) -> LogWarn; template LogError(T&&...) -> LogError; } // namespace llarp