Skip to content

Commit

Permalink
Solving issue #234
Browse files Browse the repository at this point in the history
  • Loading branch information
pinoOgni committed Aug 12, 2021
1 parent 90cab4e commit 11247ee
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 24 deletions.
10 changes: 0 additions & 10 deletions Documentation/developers/debugging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,6 @@ Usage example:
pcn_log(ctx, LOG_DEBUG, "Receiving packet from port %d", md->in_port);


The ``pcn_pkt_log(ctx, level)`` primitive sends a packet to the control plane where it is printed in a tcpdump-like format.
``ctx`` and ``level`` are the same as in ``pcn_log``.
This feature is only designed for developers, so final version of services should not include this.

Usage example:

::

pcn_pkt_log(ctx, LOG_DEBUG);


.. _logging-control-plane:

Expand Down
14 changes: 1 addition & 13 deletions src/polycubed/src/datapath_log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,6 @@ static std::regex regN(R"***(pcn_log\s*\(([\s\S]+?)\)\s*;)***");
static std::regex regNewLine(R"***(/(\r\n)+|\r+|\n+|\t+/i)***");
static std::regex regAddSpaces(R"***( +)***");

static std::regex regNPkt(R"***(pcn_pkt_log\s*\(([\s\S]+?)\)\s*;)***");

std::string DatapathLog::dp_callback(const std::smatch &m) {
std::string match = std::regex_replace(m.str(1), regNewLine, "");
match = std::regex_replace(match, regAddSpaces, " ");
Expand All @@ -231,21 +229,11 @@ std::string DatapathLog::dp_callback(const std::smatch &m) {
return new_string;
}

std::string DatapathLog::dp_callback_pkt(const std::smatch &m) {
std::string match = std::regex_replace(m.str(1), regNewLine, "");
match = std::regex_replace(match, regAddSpaces, " ");
std::string new_string = std::string(REPLACE_BASE_PKT);
new_string = DatapathLog::replace_string(new_string, "$1", match);
return new_string;
}

std::string DatapathLog::parse_log(const std::string &code) {
// remove all comments from the code before going on
auto code1 = std::regex_replace(code, regComments, "$1");
auto code2 = std::regex_replace_cb(code1, regN, DatapathLog::dp_callback);
auto code3 =
std::regex_replace_cb(code2, regNPkt, DatapathLog::dp_callback_pkt);
return BASE_CODE + code3;
return BASE_CODE + code2;
}

} // namespace polycubed
Expand Down
1 change: 0 additions & 1 deletion src/polycubed/src/datapath_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class DatapathLog {
const std::string &search,
const std::string &replace);
static std::string dp_callback(const std::smatch &m);
static std::string dp_callback_pkt(const std::smatch &m);

// replaces all the log calls to the code that does it
std::string parse_log(const std::string &code);
Expand Down

0 comments on commit 11247ee

Please sign in to comment.