OpenVPN 3 Core Library
Loading...
Searching...
No Matches
logger.hpp File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  openvpn::logging::Logger< DEFAULT_LOG_LEVEL, MAX_LEVEL >
 
class  openvpn::logging::LoggingMixin< DEFAULT_LOG_LEVEL, MAX_LEVEL, TagT >
 

Namespaces

namespace  openvpn
 
namespace  openvpn::logging
 

Macros

#define LOGGER_LOG(VERB, logger, args)
 
#define LOGGER_LOG_INFO(logger, args)   LOGGER_LOG(INFO, logger, args)
 
#define LOGGER_LOG_VERBOSE(logger, args)   LOGGER_LOG(VERB, logger, args)
 
#define LOGGER_LOG_DEBUG(logger, args)   LOGGER_LOG(DEBUG, logger, args)
 
#define LOGGER_LOG_TRACE(logger, args)   LOGGER_LOG(TRACE, logger, args)
 
#define LOGGER_LOG_ERROR(logger, args)   LOGGER_LOG(ERROR, logger, args)
 
#define OVPN_LOG_ERROR(args)   LOGGER_LOG_ERROR(log_, args)
 
#define OVPN_LOG_INFO(args)   LOGGER_LOG_INFO(log_, args)
 
#define OVPN_LOG_VERBOSE(args)   LOGGER_LOG_VERBOSE(log_, args)
 
#define OVPN_LOG_DEBUG(args)   LOGGER_LOG_DEBUG(log_, args)
 
#define OVPN_LOG_TRACE(args)   LOGGER_LOG_TRACE(log_, args)
 

Variables

constexpr int openvpn::logging::LOG_LEVEL_ERROR = 0
 
constexpr int openvpn::logging::LOG_LEVEL_INFO = 1
 
constexpr int openvpn::logging::LOG_LEVEL_VERB = 2
 
constexpr int openvpn::logging::LOG_LEVEL_DEBUG = 3
 
constexpr int openvpn::logging::LOG_LEVEL_TRACE = 4
 

Macro Definition Documentation

◆ LOGGER_LOG

#define LOGGER_LOG (   VERB,
  logger,
  args 
)
Value:
do \
{ \
if constexpr (decltype(logger)::max_log_level >= openvpn::logging::LOG_LEVEL_##VERB) \
{ \
if (logger.log_level() >= openvpn::logging::LOG_LEVEL_##VERB) \
{ \
std::ostringstream _ovpn_log_ss; \
_ovpn_log_ss << args; \
logger.log_info(_ovpn_log_ss.str()); \
} \
} \
} while (0)

Logging macro that logs with VERB verbosity using the logger named logger

The macro tries very hard to avoid executing the code that is inside args when logging is not happening

Definition at line 197 of file logger.hpp.

◆ LOGGER_LOG_DEBUG

#define LOGGER_LOG_DEBUG (   logger,
  args 
)    LOGGER_LOG(DEBUG, logger, args)

Definition at line 213 of file logger.hpp.

◆ LOGGER_LOG_ERROR

#define LOGGER_LOG_ERROR (   logger,
  args 
)    LOGGER_LOG(ERROR, logger, args)

Definition at line 215 of file logger.hpp.

◆ LOGGER_LOG_INFO

#define LOGGER_LOG_INFO (   logger,
  args 
)    LOGGER_LOG(INFO, logger, args)

Definition at line 211 of file logger.hpp.

◆ LOGGER_LOG_TRACE

#define LOGGER_LOG_TRACE (   logger,
  args 
)    LOGGER_LOG(TRACE, logger, args)

Definition at line 214 of file logger.hpp.

◆ LOGGER_LOG_VERBOSE

#define LOGGER_LOG_VERBOSE (   logger,
  args 
)    LOGGER_LOG(VERB, logger, args)

Definition at line 212 of file logger.hpp.

◆ OVPN_LOG_DEBUG

#define OVPN_LOG_DEBUG (   args)    LOGGER_LOG_DEBUG(log_, args)

Definition at line 226 of file logger.hpp.

◆ OVPN_LOG_ERROR

#define OVPN_LOG_ERROR (   args)    LOGGER_LOG_ERROR(log_, args)

These are convenience macros for classes that use the LoggingMixin to avoid specifying the logger

The spelling has been chosen to avoid conflicts with syslog.h log level constants LOG_INFO and LOG_DEBUG.

Definition at line 223 of file logger.hpp.

◆ OVPN_LOG_INFO

#define OVPN_LOG_INFO (   args)    LOGGER_LOG_INFO(log_, args)

Definition at line 224 of file logger.hpp.

◆ OVPN_LOG_TRACE

#define OVPN_LOG_TRACE (   args)    LOGGER_LOG_TRACE(log_, args)

Definition at line 227 of file logger.hpp.

◆ OVPN_LOG_VERBOSE

#define OVPN_LOG_VERBOSE (   args)    LOGGER_LOG_VERBOSE(log_, args)

Definition at line 225 of file logger.hpp.