Optimize log output
This commit is contained in:
@@ -241,21 +241,31 @@ static void packet_handler(u_char *user, const struct pcap_pkthdr *h, const u_ch
|
||||
{
|
||||
struct runtime *rte = (struct runtime *)user;
|
||||
|
||||
char *ptr = (char *)calloc(1, h->caplen);
|
||||
if (ptr == NULL)
|
||||
{
|
||||
PRINT_RED("calloc() failed");
|
||||
return;
|
||||
}
|
||||
memcpy(ptr, bytes, h->caplen);
|
||||
|
||||
struct packet pkt;
|
||||
memset(&pkt, 0, sizeof(pkt));
|
||||
packet_parse(&pkt, (const char *)bytes, h->caplen);
|
||||
packet_parse(&pkt, (const char *)ptr, h->caplen);
|
||||
rte->pcap_count++;
|
||||
|
||||
if (rte->print_verbose)
|
||||
{
|
||||
PRINT_GREEN("frame=%lu len=%u", rte->pcap_count, h->caplen);
|
||||
packet_print(&pkt);
|
||||
packet_dump_hex(&pkt, STDOUT_FILENO);
|
||||
}
|
||||
|
||||
if (rte->tshark_format)
|
||||
{
|
||||
tshark_format(rte, &pkt);
|
||||
}
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
static void usage(char *cmd)
|
||||
|
||||
@@ -175,12 +175,12 @@ static void on_session_free(struct session *sess, void *arg)
|
||||
|
||||
char buff[PATH_MAX] = {0};
|
||||
session_to_str(exdata->sess, 0, buff, sizeof(buff) - 1);
|
||||
session_debugger_log(exdata->dbg->fd, "sess free: %s", buff);
|
||||
session_debugger_log(exdata->dbg->fd, "session free: %s", buff);
|
||||
|
||||
snprintf(buff, sizeof(buff),
|
||||
"==========================================================\n"
|
||||
"C2S Data Packets : %6lu | C2S Data Bytes : %6lu\n"
|
||||
"S2C Data Packets : %6lu | S2C Data Bytes : %6lu\n"
|
||||
"C2S Data Packets : %6lu | C2S Data Bytes : %6lu\n"
|
||||
"S2C Data Packets : %6lu | S2C Data Bytes : %6lu\n"
|
||||
"----------------------------------------------------------\n"
|
||||
"C2S Control Packets : %6lu | C2S Control Bytes : %6lu\n"
|
||||
"S2C Control Packets : %6lu | S2C Control Bytes : %6lu\n"
|
||||
@@ -189,7 +189,7 @@ static void on_session_free(struct session *sess, void *arg)
|
||||
"S2C TCP Segments : %6lu | S2C TCP Bytes : %6lu\n"
|
||||
"----------------------------------------------------------\n"
|
||||
"C2S UDP Payload : %6lu | C2S UDP Bytes : %6lu\n"
|
||||
"S2C UDP Payload : %6lu | S2C UDP Bytes : %6lu\n",
|
||||
"S2C UDP Payload : %6lu | S2C UDP Bytes : %6lu",
|
||||
exdata->c2s_rx_data_pkts, exdata->c2s_rx_data_bytes,
|
||||
exdata->s2c_rx_data_pkts, exdata->s2c_rx_data_bytes,
|
||||
exdata->c2s_rx_ctrl_pkts, exdata->c2s_rx_ctrl_bytes,
|
||||
@@ -438,7 +438,7 @@ struct stellar_module *session_debugger_on_init(struct stellar_module_manager *m
|
||||
}
|
||||
stellar_module_set_ctx(dbg_mod, dbg);
|
||||
|
||||
STELLAR_LOG_FATAL(dbg->logger, "session debugger", "session_debugger initialized")
|
||||
STELLAR_LOG_FATAL(dbg->logger, "session debugger", "session_debugger init")
|
||||
|
||||
return dbg_mod;
|
||||
}
|
||||
@@ -450,7 +450,7 @@ void session_debugger_on_exit(struct stellar_module_manager *mod_mgr, struct ste
|
||||
struct session_debugger *dbg = stellar_module_get_ctx(mod);
|
||||
if (dbg)
|
||||
{
|
||||
STELLAR_LOG_FATAL(dbg->logger, "session debugger", "session_debugger exited")
|
||||
STELLAR_LOG_FATAL(dbg->logger, "session debugger", "session_debugger exit")
|
||||
session_debugger_free(dbg);
|
||||
}
|
||||
stellar_module_free(mod);
|
||||
|
||||
Reference in New Issue
Block a user