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