7 #if defined(__BGP_DEBUG__)
10 bool BgpDebug::enable_ = (getenv(
"BGP_DEBUG") != NULL);
11 bool BgpDebug::enable_stack_trace_ = (getenv(
"BGP_DEBUG_STACK_TRACE") != NULL);
13 #define COLOR_RESET "\e[m"
14 #define COLOR_BLACK "\e[0;30m"
15 #define COLOR_RED "\e[0;31m"
16 #define COLOR_GREEN "\e[0;32m"
17 #define COLOR_BROWN "\e[0;33m"
18 #define COLOR_BLUE "\e[0;34m"
19 #define COLOR_MAGENTA "\e[0;35m"
20 #define COLOR_CYAN "\e[0;36m"
21 #define COLOR_GRAY "\e[0;37m"
22 #define COLOR_DARKGRAY "\e[1;30m"
23 #define COLOR_LIGHTBLUE "\e[1;34m"
24 #define COLOR_LIGHTGREEN "\e[1;32m"
25 #define COLOR_LIGHTCYAN "\e[1;36m"
26 #define COLOR_LIGHTRED "\e[1;31m"
27 #define COLOR_LIGHTPURPLE "\e[1;35m"
28 #define COLOR_YELLOW "\e[1;33m"
29 #define COLOR_WHITE "\e[1;37m"
32 const char *
function,
int line,
char *msg) {
42 size_t buf_size = 1024 * 1024;
43 buf =
static_cast<char *
>(malloc(buf_size));
46 const char *server_name = (peer && peer->
server()) ?
48 const char *instance_name =
51 const char *table_name = table ?
53 const char *peer_name = peer ? peer->
ToString().c_str() :
"Unknown";
54 const char *route_name = rt ? rt->
ToString().c_str() :
"Unknown";
56 str += snprintf(str, buf_size - (str - buf),
"\n%s:%s:%d: ",
57 file,
function, line);
58 if (strcmp(server_name,
"Unknown")) {
59 str += snprintf(str, buf_size - (str - buf),
60 COLOR_BROWN
"Serv %s(%p); ",
61 server_name, peer->
server());
63 if (strcmp(instance_name,
"Unknown")) {
64 str += snprintf(str, buf_size - (str - buf),
65 COLOR_RED
"Inst %s(%p); ", instance_name,
68 if (strcmp(table_name,
"Unknown")) {
69 if (strcmp(table_name,
"inet"))
70 str += snprintf(str, buf_size - (str - buf),
71 COLOR_LIGHTBLUE
"Tabl %s(%p); ",
74 str += snprintf(str, buf_size - (str - buf),
75 COLOR_BLUE
"Tabl %s(%p); ",
78 if (strcmp(peer_name,
"Unknown")) {
79 str += snprintf(str, buf_size - (str - buf),
80 COLOR_GREEN
"Peer %s(%s)(%p), ", peer_name,
83 if (strcmp(route_name,
"Unknown")) {
84 str += snprintf(str, buf_size - (str - buf),
85 COLOR_MAGENTA
"Route %s(%p)", route_name, rt);
87 str += snprintf(str, buf_size - (str - buf), COLOR_CYAN
"\n %s", msg);
88 str += snprintf(str, buf_size - (str - buf),
"\n"
89 "------------------------------------------"
90 "------------------------------------------");
91 str += snprintf(str, buf_size - (str - buf), COLOR_RESET);
97 #endif // __BGP_DEBUG__
static void Log(const std::string &msg)
RoutingInstance * routing_instance()
const std::string & name() const
virtual Address::Family family() const =0
#define BGP_LOG_STR(obj, level, flags, arg)
virtual const std::string GetStateName() const =0
virtual const std::string & ToString() const =0
virtual std::string ToString() const =0
virtual BgpServer * server()=0
static std::string FamilyToString(Family fmly)
virtual std::string ToString() const