Hi, Alexandre
I need to generate a log with STP messages
You want to output the log like "[STP][INFO] dpid=0000000000000001:
[port=1] DESIGNATED_PORT / LISTEN" to the log file, right?
The log is output in Stp class in ryu/lib/stplib.py, but currently,
"--log-file" option is not passed to Stp,
so it always logs to stdout.
The quick fix is making handlers to output to the file in Stp.
Also I need to collect the time between the messages
Showing time in logs is enough?
You can do it by putting "%(asctime)s" in the log format.
I attached the quick fix for these to this mail.
Could you try this?
Thanks,
Fujimoto
On 2017年11月12日 10:50, Alexandre Alves dos Santos de Campos wrote:
Hello people,
I need your help. I need to generate a log with STP messages, but when
I use the --log-file = arq.txt option, the STP messages are not
inserted in the file.
Also I need to collect the time between the messages, measure the STP
call time in the SDN Networks - it is a job for the MS in IS.
I read the RYU Book, but I did not find the syntax for these situations
Can you help me ?
Thank you in advance.
Alexandre Campos
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel
diff --git a/ryu/lib/stplib.py b/ryu/lib/stplib.py
index 97752f1..d45d847 100644
--- a/ryu/lib/stplib.py
+++ b/ryu/lib/stplib.py
@@ -16,7 +16,9 @@
import datetime
import logging
+import logging.handlers
+from ryu import cfg
from ryu.base import app_manager
from ryu.controller import event
from ryu.controller import handler
@@ -35,6 +37,7 @@ from ryu.ofproto import ofproto_v1_0
from ryu.ofproto import ofproto_v1_2
from ryu.ofproto import ofproto_v1_3
+CONF = cfg.CONF
MAX_PORT_NO = 0xfff
@@ -198,10 +201,16 @@ class Stp(app_manager.RyuApp):
def _set_logger(self):
self.logger.propagate = False
hdlr = logging.StreamHandler()
- fmt_str = '[STP][%(levelname)s] dpid=%(dpid)s: %(message)s'
+ fmt_str = \
+ '[STP][%(asctime)s][%(levelname)s] dpid=%(dpid)s: %(message)s'
hdlr.setFormatter(logging.Formatter(fmt_str))
self.logger.addHandler(hdlr)
+ if CONF.log_file:
+ hdlr2 = logging.handlers.WatchedFileHandler(CONF.log_file)
+ hdlr2.setFormatter(logging.Formatter(fmt_str))
+ self.logger.addHandler(hdlr2)
+
def set_config(self, config):
""" Use this API if you want to set up configuration
of each bridge and ports.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel