X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=VNFs%2FDPPD-PROX%2Flog.c;h=2fa63f34ffb3f8cfbf0854a8ba225cffc625a3fc;hb=8442f6a8ce0962d818b7cd800150980c65983719;hp=b07076de598a9a87808994929209192949dd50cb;hpb=ab615dd91dcb355615b1f1f7266d878b70b35b4d;p=samplevnf.git diff --git a/VNFs/DPPD-PROX/log.c b/VNFs/DPPD-PROX/log.c index b07076de..2fa63f34 100644 --- a/VNFs/DPPD-PROX/log.c +++ b/VNFs/DPPD-PROX/log.c @@ -25,6 +25,7 @@ #include #include "log.h" +#include "quit.h" #include "display.h" #include "defaults.h" #include "etypes.h" @@ -81,6 +82,13 @@ void plog_init(const char *log_name, int log_name_pid) tsc_off = rte_rdtsc() + 2500000000; } +void plog_end(void) +{ + if (fp) + fclose(fp); + fp = NULL; +} + int plog_set_lvl(int lvl) { if (lvl <= PROX_MAX_LOG_LVL) { @@ -205,6 +213,10 @@ static int vplog(int lvl, const char *format, va_list ap, const struct rte_mbuf ret--; ret += dump_pkt(buf + ret, sizeof(buf) - ret, mbuf); } + + if (lvl == PROX_LOG_PANIC) + PROX_PANIC(1, "%s", buf); + plog_buf(buf); if (lvl == PROX_LOG_WARN) { @@ -271,6 +283,23 @@ int plog_err(const char *fmt, ...) return ret; } +int plog_err_or_panic(int do_panic, const char *fmt, ...) +{ + va_list ap; + int ret; + + va_start(ap, fmt); + if (do_panic) { + ret = vplog(PROX_LOG_PANIC, fmt, ap, NULL, 0); + va_end(ap); + return ret; + } else { + ret = vplog(PROX_LOG_ERR, fmt, ap, NULL, 0); + va_end(ap); + return ret; + } +} + int plogx_err(const char *fmt, ...) { va_list ap;