OpenSDN source code
bgp_log.h File Reference
#include "sandesh/sandesh_trace.h"
#include "sandesh/common/vns_types.h"
#include "base/logging.h"
#include "bgp/bgp_log_types.h"
#include "bgp/bgp_server.h"
#include "bgp/ipeer.h"
#include "bgp/bgp_table.h"
Include dependency graph for bgp_log.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 bgp_log_test
 

Macros

#define BGP_DEBUG_UT(str)    BGP_LOG_STR(BgpMessage, Sandesh::LoggingUtLevel(), BGP_LOG_FLAG_ALL, str)
 
#define BGP_WARN_UT(str)    BGP_LOG_STR(BgpMessage, SandeshLevel::UT_WARN, BGP_LOG_FLAG_ALL, str)
 
#define BGP_TRACE_BUF   "BgpTraceBuf"
 
#define BGP_PEER_OBJECT_TRACE_BUF   "BgpPeerObjectTraceBuf"
 
#define BGP_LOG_FLAG_SYSLOG   1
 
#define BGP_LOG_FLAG_TRACE   2
 
#define BGP_LOG_FLAG_ALL   (BGP_LOG_FLAG_SYSLOG | BGP_LOG_FLAG_TRACE)
 
#define BGP_UVE_SEND(type, object)
 
#define BGP_UVE_SEND2(type, object, arg)
 
#define BGP_LOG(obj, level, flags, ...)
 
#define BGP_LOG_NOTICE(obj, flags, ...)
 
#define BGP_LOG_STR(obj, level, flags, arg)
 
#define BGP_LOG_ERROR_STR(obj, level, flags, arg)
 
#define BGP_LOG_WARNING_STR(obj, flags, arg)
 
#define BGP_LOG_NOTICE_STR(obj, flags, arg)
 
#define BGP_LOG_SERVER(peer, table)
 
#define BGP_PEER_DIR_OUT   "SEND"
 
#define BGP_PEER_DIR_IN   "RECV"
 
#define BGP_PEER_DIR_NA   ""
 
#define BGP_LOG_PEER_INTERNAL(type, peer, level, flags, ...)
 
#define BGP_LOG_PEER(type, peer, level, flags, dir, arg)
 
#define BGP_LOG_PEER_NOTICE(type, peer, flags, dir, arg)
 
#define BGP_LOG_PEER_WARNING(type, peer, flags, dir, arg)
 
#define BGP_LOG_PEER_CRITICAL(type, peer, flags, dir, arg)
 
#define BGP_LOG_PEER_TABLE(peer, level, flags, tbl, arg)
 
#define BGP_LOG_PEER_INSTANCE(peer, instance, level, flags, arg)
 
#define BGP_LOG_PEER_INSTANCE_WARNING(peer, instance, flags, arg)
 
#define BGP_LOG_PEER_INSTANCE_CRITICAL(peer, instance, dir, flags, arg)
 
#define BGP_LOG_ROUTE(table, peer, route, arg)
 
#define BGP_LOG_TABLE(table, level, flags, arg)
 
#define BGP_CONFIG_LOG_INTERNAL(type, server, level, flags, ...)
 
#define BGP_CONFIG_LOG_INSTANCE(type, server, rtinstance, level, flags, ...)
 
#define BGP_CONFIG_LOG_NEIGHBOR(type, server, neighbor, level, flags, ...)
 
#define BGP_CONFIG_LOG_PEERING(type, server, peering, level, flags, ...)
 
#define BGP_CONFIG_LOG_PROTOCOL(type, server, protocol, level, flags, ...)
 
#define BGP_TRACE_PEER_OBJECT(peer, peer_info)
 
#define BGP_TRACE_PEER_PACKET(peer, msg, size, level)
 

Functions

void bgp_log_test::init ()
 
void bgp_log_test::init (std::string log_file, unsigned long log_file_size, unsigned long log_file_index, bool enable_syslog, std::string syslog_facility, std::string ident, std::string log_level)
 
bool bgp_log_test::unit_test ()
 
void bgp_log_test::LogServerName (const BgpServer *server)
 
void bgp_log_test::LogServerName (const IPeer *ipeer, const BgpTable *table)
 

Variables

SandeshTraceBufferPtr BgpTraceBuf
 
SandeshTraceBufferPtr BgpPeerObjectTraceBuf
 

Macro Definition Documentation

◆ BGP_CONFIG_LOG_INSTANCE

#define BGP_CONFIG_LOG_INSTANCE (   type,
  server,
  rtinstance,
  level,
  flags,
  ... 
)
Value:
BGP_CONFIG_LOG_INTERNAL(Instance##type, server, level, flags, \
(rtinstance)->name(), ##__VA_ARGS__);
#define BGP_CONFIG_LOG_INTERNAL(type, server, level, flags,...)
Definition: bgp_log.h:271
uint8_t type
Definition: load_balance.h:2

Definition at line 285 of file bgp_log.h.

◆ BGP_CONFIG_LOG_INTERNAL

#define BGP_CONFIG_LOG_INTERNAL (   type,
  server,
  level,
  flags,
  ... 
)
Value:
do { \
if (LoggingDisabled()) break; \
if ((flags) & BGP_LOG_FLAG_SYSLOG) { \
BgpConfig##type##Log::Send("BGPConfig", level, \
__FILE__, __LINE__, ##__VA_ARGS__); \
} \
if ((flags) & BGP_LOG_FLAG_TRACE) { \
BgpConfig##type##Trace::TraceMsg(BgpTraceBuf, \
__FILE__, __LINE__, ##__VA_ARGS__); \
} \
} while (false)
#define BGP_LOG_FLAG_SYSLOG
Definition: bgp_log.h:43
SandeshTraceBufferPtr BgpTraceBuf
#define BGP_LOG_FLAG_TRACE
Definition: bgp_log.h:44
bool LoggingDisabled()
Definition: logging.cc:56
void LogServerName(const BgpServer *server)
Definition: bgp_log.cc:58

Definition at line 271 of file bgp_log.h.

◆ BGP_CONFIG_LOG_NEIGHBOR

#define BGP_CONFIG_LOG_NEIGHBOR (   type,
  server,
  neighbor,
  level,
  flags,
  ... 
)
Value:
BGP_CONFIG_LOG_INTERNAL(Neighbor##type, server, level, flags, \
(neighbor)->name(), ##__VA_ARGS__);

Definition at line 289 of file bgp_log.h.

◆ BGP_CONFIG_LOG_PEERING

#define BGP_CONFIG_LOG_PEERING (   type,
  server,
  peering,
  level,
  flags,
  ... 
)
Value:
BGP_CONFIG_LOG_INTERNAL(Peering##type, server, level, flags, \
(peering)->name(), ##__VA_ARGS__);

Definition at line 293 of file bgp_log.h.

◆ BGP_CONFIG_LOG_PROTOCOL

#define BGP_CONFIG_LOG_PROTOCOL (   type,
  server,
  protocol,
  level,
  flags,
  ... 
)
Value:
BGP_CONFIG_LOG_INTERNAL(Protocol##type, server, level, flags, \
(protocol)->instance()->name(), ##__VA_ARGS__);

Definition at line 297 of file bgp_log.h.

◆ BGP_DEBUG_UT

#define BGP_DEBUG_UT (   str)     BGP_LOG_STR(BgpMessage, Sandesh::LoggingUtLevel(), BGP_LOG_FLAG_ALL, str)

Definition at line 30 of file bgp_log.h.

◆ BGP_LOG

#define BGP_LOG (   obj,
  level,
  flags,
  ... 
)
Value:
do { \
if (LoggingDisabled()) break; \
if ((flags) & BGP_LOG_FLAG_SYSLOG) { \
obj##Log::Send("BGP", level, __FILE__, __LINE__, ##__VA_ARGS__); \
if (bgp_log_test::unit_test()) break; \
} \
if ((flags) & BGP_LOG_FLAG_TRACE) { \
obj##Trace::TraceMsg(BgpTraceBuf, __FILE__, __LINE__, \
##__VA_ARGS__); \
} \
} while (false)
bool unit_test()
Definition: bgp_log.cc:54

Definition at line 60 of file bgp_log.h.

◆ BGP_LOG_ERROR_STR

#define BGP_LOG_ERROR_STR (   obj,
  level,
  flags,
  arg 
)
Value:
do { \
if (LoggingDisabled()) break; \
std::ostringstream _os; \
_os << arg; \
BGP_LOG(obj##Error, SandeshLevel::SYS_ERR, flags, _os.str()); \
} while (false)
#define BGP_LOG(obj, level, flags,...)
Definition: bgp_log.h:60

Definition at line 99 of file bgp_log.h.

◆ BGP_LOG_FLAG_ALL

#define BGP_LOG_FLAG_ALL   (BGP_LOG_FLAG_SYSLOG | BGP_LOG_FLAG_TRACE)

Definition at line 45 of file bgp_log.h.

◆ BGP_LOG_FLAG_SYSLOG

#define BGP_LOG_FLAG_SYSLOG   1

Definition at line 43 of file bgp_log.h.

◆ BGP_LOG_FLAG_TRACE

#define BGP_LOG_FLAG_TRACE   2

Definition at line 44 of file bgp_log.h.

◆ BGP_LOG_NOTICE

#define BGP_LOG_NOTICE (   obj,
  flags,
  ... 
)
Value:
do { \
if (LoggingDisabled()) break; \
if ((flags) & BGP_LOG_FLAG_SYSLOG) { \
obj##Notice##Log::Send("BGP", SandeshLevel::SYS_NOTICE, __FILE__, \
__LINE__, ##__VA_ARGS__); \
if (bgp_log_test::unit_test()) break; \
} \
if ((flags) & BGP_LOG_FLAG_TRACE) { \
const std::string __trace_buf(BGP_TRACE_BUF); \
obj##Notice##Trace::TraceMsg(BgpTraceBuf, __FILE__, __LINE__, \
##__VA_ARGS__); \
} \
} while (false)
#define BGP_TRACE_BUF
Definition: bgp_log.h:37

Definition at line 74 of file bgp_log.h.

◆ BGP_LOG_NOTICE_STR

#define BGP_LOG_NOTICE_STR (   obj,
  flags,
  arg 
)
Value:
do { \
if (LoggingDisabled()) break; \
std::ostringstream _os; \
_os << arg; \
BGP_LOG(obj##Notice, SandeshLevel::SYS_NOTICE, flags, _os.str()); \
} while (false)

Definition at line 117 of file bgp_log.h.

◆ BGP_LOG_PEER

#define BGP_LOG_PEER (   type,
  peer,
  level,
  flags,
  dir,
  arg 
)
Value:
do { \
if (LoggingDisabled()) break; \
\
BGP_LOG_SERVER(peer, (BgpTable *) 0); \
std::ostringstream _os; \
_os << arg; \
BGP_LOG_PEER_INTERNAL(type, peer, level, flags, dir, _os.str()); \
} while (false)
#define BGP_LOG_SERVER(peer, table)
Definition: bgp_log.h:129
#define BGP_LOG_PEER_INTERNAL(type, peer, level, flags,...)
Definition: bgp_log.h:143

Definition at line 160 of file bgp_log.h.

◆ BGP_LOG_PEER_CRITICAL

#define BGP_LOG_PEER_CRITICAL (   type,
  peer,
  flags,
  dir,
  arg 
)
Value:
do { \
if (LoggingDisabled()) break; \
\
BGP_LOG_SERVER(peer, (BgpTable *) 0); \
std::ostringstream _os; \
_os << arg; \
BGP_LOG_PEER_INTERNAL(type##Critical, peer, SandeshLevel::SYS_CRIT, \
flags, dir, _os.str()); \
} while (false)

Definition at line 195 of file bgp_log.h.

◆ BGP_LOG_PEER_INSTANCE

#define BGP_LOG_PEER_INSTANCE (   peer,
  instance,
  level,
  flags,
  arg 
)
Value:
do { \
if (LoggingDisabled()) break; \
std::ostringstream _os; \
_os << arg; \
BGP_LOG_PEER_INTERNAL(Instance, peer, level, flags, BGP_PEER_DIR_NA, \
instance, _os.str()); \
} while (false)
#define BGP_PEER_DIR_NA
Definition: bgp_log.h:141

Definition at line 219 of file bgp_log.h.

◆ BGP_LOG_PEER_INSTANCE_CRITICAL

#define BGP_LOG_PEER_INSTANCE_CRITICAL (   peer,
  instance,
  dir,
  flags,
  arg 
)
Value:
do { \
if (LoggingDisabled()) break; \
std::ostringstream _os; \
_os << arg; \
BGP_LOG_PEER_INTERNAL(Instance, peer, SandeshLevel::SYS_CRIT, flags, \
dir, instance, _os.str()); \
} while (false)

Definition at line 238 of file bgp_log.h.

◆ BGP_LOG_PEER_INSTANCE_WARNING

#define BGP_LOG_PEER_INSTANCE_WARNING (   peer,
  instance,
  flags,
  arg 
)
Value:
do { \
if (LoggingDisabled()) break; \
std::ostringstream _os; \
_os << arg; \
BGP_LOG_PEER_INTERNAL(Instance, peer, SandeshLevel::SYS_WARN, flags, \
instance, _os.str()); \
} while (false)

Definition at line 228 of file bgp_log.h.

◆ BGP_LOG_PEER_INTERNAL

#define BGP_LOG_PEER_INTERNAL (   type,
  peer,
  level,
  flags,
  ... 
)
Value:
do { \
const IPeer *_peer = dynamic_cast<const IPeer *>(peer); \
std::string _peer_name; \
if (_peer) { \
_peer_name = _peer->ToUVEKey(); \
} else { \
_peer_name = "Unknown"; \
} \
if (_peer && _peer->IsXmppPeer()) { \
BGP_LOG(XmppPeer ## type, level, flags, _peer_name, ##__VA_ARGS__);\
} else { \
BGP_LOG(BgpPeer ## type, level, flags, _peer_name, ##__VA_ARGS__); \
} \
} while (false)
Definition: ipeer.h:187
virtual const std::string & ToUVEKey() const =0

Definition at line 143 of file bgp_log.h.

◆ BGP_LOG_PEER_NOTICE

#define BGP_LOG_PEER_NOTICE (   type,
  peer,
  flags,
  dir,
  arg 
)
Value:
do { \
if (LoggingDisabled()) break; \
\
BGP_LOG_SERVER(peer, (BgpTable *) 0); \
std::ostringstream _os; \
_os << arg; \
BGP_LOG_PEER_INTERNAL(type##Notice, peer, SandeshLevel::SYS_NOTICE, \
flags, dir, _os.str()); \
} while (false)

Definition at line 171 of file bgp_log.h.

◆ BGP_LOG_PEER_TABLE

#define BGP_LOG_PEER_TABLE (   peer,
  level,
  flags,
  tbl,
  arg 
)
Value:
do { \
if (LoggingDisabled()) break; \
BGP_LOG_SERVER(peer, tbl); \
std::ostringstream _os; \
_os << arg; \
BGP_LOG_PEER_INTERNAL(Table, peer, level, flags, BGP_PEER_DIR_NA, \
(tbl) ? (tbl)->name() : "", \
((tbl) && (tbl)->routing_instance()) ? \
(tbl)->routing_instance()->name() : "", \
_os.str()); \
} while (false)

Definition at line 206 of file bgp_log.h.

◆ BGP_LOG_PEER_WARNING

#define BGP_LOG_PEER_WARNING (   type,
  peer,
  flags,
  dir,
  arg 
)
Value:
do { \
if (LoggingDisabled()) break; \
\
BGP_LOG_SERVER(peer, (BgpTable *) 0); \
std::ostringstream _os; \
_os << arg; \
BGP_LOG_PEER_INTERNAL(type##Warning, peer, SandeshLevel::SYS_WARN, \
flags, dir, _os.str()); \
} while (false)

Definition at line 183 of file bgp_log.h.

◆ BGP_LOG_ROUTE

#define BGP_LOG_ROUTE (   table,
  peer,
  route,
  arg 
)
Value:
do { \
if (LoggingDisabled()) break; \
BGP_LOG_SERVER(peer, table); \
std::ostringstream _os; \
_os << arg; \
BGP_LOG_PEER_INTERNAL(Route, peer, SandeshLevel::SYS_DEBUG, \
(route) ? (route)->ToString() : "", \
(table) ? (table)->name() : ""); \
} while (false)
Definition: route.h:15
static string ToString(PhysicalDevice::ManagementProtocol proto)

Definition at line 248 of file bgp_log.h.

◆ BGP_LOG_SERVER

#define BGP_LOG_SERVER (   peer,
  table 
)
Value:
if (LoggingDisabled()) break; \
if (dynamic_cast<const IPeer *>(peer) && \
dynamic_cast<const IPeer *>(peer)->server() && \
dynamic_cast<const IPeer *>(peer)->server()->logging_disabled()) \
break; \
bgp_log_test::LogServerName(dynamic_cast<const IPeer *>(peer), \
dynamic_cast<const BgpTable *>(table)); \

Definition at line 129 of file bgp_log.h.

◆ BGP_LOG_STR

#define BGP_LOG_STR (   obj,
  level,
  flags,
  arg 
)
Value:
do { \
if (LoggingDisabled()) break; \
std::ostringstream _os; \
_os << arg; \
BGP_LOG(obj, level, flags, _os.str()); \
} while (false)

Definition at line 90 of file bgp_log.h.

◆ BGP_LOG_TABLE

#define BGP_LOG_TABLE (   table,
  level,
  flags,
  arg 
)
Value:
do { \
if (LoggingDisabled()) break; \
BGP_LOG_SERVER((const IPeer *) 0, table); \
std::ostringstream _os; \
_os << arg; \
BGP_LOG(BgpTable, level, flags, (table) ? (table)->name() : "", \
_os.str()); \
} while (false)

Definition at line 261 of file bgp_log.h.

◆ BGP_LOG_WARNING_STR

#define BGP_LOG_WARNING_STR (   obj,
  flags,
  arg 
)
Value:
do { \
if (LoggingDisabled()) break; \
std::ostringstream _os; \
_os << arg; \
BGP_LOG(obj##Warning, SandeshLevel::SYS_WARN, flags, _os.str()); \
} while (false)

Definition at line 108 of file bgp_log.h.

◆ BGP_PEER_DIR_IN

#define BGP_PEER_DIR_IN   "RECV"

Definition at line 140 of file bgp_log.h.

◆ BGP_PEER_DIR_NA

#define BGP_PEER_DIR_NA   ""

Definition at line 141 of file bgp_log.h.

◆ BGP_PEER_DIR_OUT

#define BGP_PEER_DIR_OUT   "SEND"

Definition at line 139 of file bgp_log.h.

◆ BGP_PEER_OBJECT_TRACE_BUF

#define BGP_PEER_OBJECT_TRACE_BUF   "BgpPeerObjectTraceBuf"

Definition at line 38 of file bgp_log.h.

◆ BGP_TRACE_BUF

#define BGP_TRACE_BUF   "BgpTraceBuf"

Definition at line 37 of file bgp_log.h.

◆ BGP_TRACE_PEER_OBJECT

#define BGP_TRACE_PEER_OBJECT (   peer,
  peer_info 
)
Value:
do { \
if (LoggingDisabled()) break; \
BGP_LOG_SERVER(peer, (BgpTable *) 0); \
BgpPeerObjectTrace::TraceMsg(BgpPeerObjectTraceBuf, __FILE__, __LINE__,\
peer_info); \
} while (false)
SandeshTraceBufferPtr BgpPeerObjectTraceBuf

Definition at line 303 of file bgp_log.h.

◆ BGP_TRACE_PEER_PACKET

#define BGP_TRACE_PEER_PACKET (   peer,
  msg,
  size,
  level 
)
Value:
do { \
if (LoggingDisabled()) break; \
if ((level) > Sandesh::LoggingLevel()) break; \
BgpPeerInfo peer_info; \
\
BGP_LOG_SERVER(peer, (BgpTable *) 0); \
(peer)->state_machine()->SetDataCollectionKey(&peer_info); \
peer_info.set_packet_data((peer)->BytesToHexString(msg, size)); \
BGP_TRACE_PEER_OBJECT(peer, peer_info); \
} while (false)
#define BGP_TRACE_PEER_OBJECT(peer, peer_info)
Definition: bgp_log.h:303

Definition at line 311 of file bgp_log.h.

◆ BGP_UVE_SEND

#define BGP_UVE_SEND (   type,
  object 
)
Value:
do { \
if (LoggingDisabled()) break; \
type::Send(object); \
} while (false) \

Definition at line 47 of file bgp_log.h.

◆ BGP_UVE_SEND2

#define BGP_UVE_SEND2 (   type,
  object,
  arg 
)
Value:
do { \
if (LoggingDisabled()) break; \
type::Send(object, arg); \
} while (false) \

Definition at line 53 of file bgp_log.h.

◆ BGP_WARN_UT

#define BGP_WARN_UT (   str)     BGP_LOG_STR(BgpMessage, SandeshLevel::UT_WARN, BGP_LOG_FLAG_ALL, str)

Definition at line 32 of file bgp_log.h.

Variable Documentation

◆ BgpPeerObjectTraceBuf

SandeshTraceBufferPtr BgpPeerObjectTraceBuf
extern

◆ BgpTraceBuf

SandeshTraceBufferPtr BgpTraceBuf
extern