Kea  1.5.0
db_log.h File Reference

We want to reuse the database backend connection and exchange code for other uses, in particular for hook libraries. More...

#include <log/macros.h>
#include <map>
#include <list>
+ Include dependency graph for db_log.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  isc::db::DbLogger
 Database logger class. More...
 

Namespaces

 isc
 Defines the logger used by the top-level component of kea-dhcp-ddns.
 
 isc::db
 

Macros

#define DB_LOG_DEBUG(LEVEL, MESSAGE)
 Macros. More...
 
#define DB_LOG_INFO(MESSAGE)
 
#define DB_LOG_WARN(MESSAGE)
 
#define DB_LOG_ERROR(MESSAGE)
 
#define DB_LOG_FATAL(MESSAGE)
 

Typedefs

typedef std::list< DbLogger > isc::db::DbLoggerStack
 Database logger stack. More...
 

Enumerations

enum  isc::db::DbMessageID {
  isc::db::DB_INVALID_ACCESS, isc::db::PGSQL_DEALLOC_ERROR, isc::db::PGSQL_FATAL_ERROR, isc::db::PGSQL_START_TRANSACTION,
  isc::db::PGSQL_COMMIT, isc::db::PGSQL_ROLLBACK, isc::db::MYSQL_FATAL_ERROR, isc::db::MYSQL_START_TRANSACTION,
  isc::db::MYSQL_COMMIT, isc::db::MYSQL_ROLLBACK, isc::db::CQL_DEALLOC_ERROR, isc::db::CQL_CONNECTION_BEGIN_TRANSACTION,
  isc::db::CQL_CONNECTION_COMMIT, isc::db::CQL_CONNECTION_ROLLBACK
}
 Database messages. More...
 

Functions

void isc::db::checkDbLoggerStack ()
 Check database logger stack. More...
 

Detailed Description

We want to reuse the database backend connection and exchange code for other uses, in particular for hook libraries.

But this code includes some calls to the system logger for debug and uncommon cases and of course we do not want to get log messages from a hook library to seem to come from DHCP server core.

The solution is to use a database logger which calls the right logger with mapped messages.

Definition in file db_log.h.

Macro Definition Documentation

◆ DB_LOG_DEBUG

#define DB_LOG_DEBUG (   LEVEL,
  MESSAGE 
)
Value:
if (!db_logger_stack.back().logger_.isDebugEnabled((LEVEL))) { \
isc::db::db_logger_stack.back().logger_.debug((LEVEL), \
isc::db::db_logger_stack.back().translateMessage((MESSAGE)))
DbLoggerStack db_logger_stack
Global database logger stack (initialized to dhcpsrv logger)
Definition: db_log.cc:50
void checkDbLoggerStack()
Check database logger stack.
Definition: db_log.cc:62

Macros.

Definition at line 115 of file db_log.h.

◆ DB_LOG_ERROR

#define DB_LOG_ERROR (   MESSAGE)
Value:
if (!isc::db::db_logger_stack.back().logger_.isErrorEnabled()) { \
isc::db::db_logger_stack.back().logger_.error( \
isc::db::db_logger_stack.back().translateMessage((MESSAGE)))
DbLoggerStack db_logger_stack
Global database logger stack (initialized to dhcpsrv logger)
Definition: db_log.cc:50
void checkDbLoggerStack()
Check database logger stack.
Definition: db_log.cc:62

Definition at line 137 of file db_log.h.

◆ DB_LOG_FATAL

#define DB_LOG_FATAL (   MESSAGE)
Value:
if (!isc::db::db_logger_stack.back().logger_.isFatalEnabled()) { \
isc::db::db_logger_stack.back().logger_.fatal( \
isc::db::db_logger_stack.back().translateMessage((MESSAGE)))
DbLoggerStack db_logger_stack
Global database logger stack (initialized to dhcpsrv logger)
Definition: db_log.cc:50
void checkDbLoggerStack()
Check database logger stack.
Definition: db_log.cc:62

Definition at line 144 of file db_log.h.

◆ DB_LOG_INFO

#define DB_LOG_INFO (   MESSAGE)
Value:
if (!isc::db::db_logger_stack.back().logger_.isInfoEnabled()) { \
isc::db::db_logger_stack.back().logger_.info( \
isc::db::db_logger_stack.back().translateMessage((MESSAGE)))
DbLoggerStack db_logger_stack
Global database logger stack (initialized to dhcpsrv logger)
Definition: db_log.cc:50
void checkDbLoggerStack()
Check database logger stack.
Definition: db_log.cc:62

Definition at line 123 of file db_log.h.

◆ DB_LOG_WARN

#define DB_LOG_WARN (   MESSAGE)
Value:
if (!isc::db::db_logger_stack.back().logger_.isWarnEnabled()) { \
isc::db::db_logger_stack.back().logger_.warn( \
isc::db::db_logger_stack.back().translateMessage((MESSAGE)))
DbLoggerStack db_logger_stack
Global database logger stack (initialized to dhcpsrv logger)
Definition: db_log.cc:50
void checkDbLoggerStack()
Check database logger stack.
Definition: db_log.cc:62

Definition at line 130 of file db_log.h.