vlog: Add vlog/close command.
[cascardo/ovs.git] / python / ovs / vlog.py
index b41f2f0..4996387 100644 (file)
@@ -1,5 +1,5 @@
 
-# Copyright (c) 2011, 2012, 2013 Nicira, Inc.
+# Copyright (c) 2011, 2012, 2013, 2015, 2016 Nicira, Inc.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -241,6 +241,8 @@ class Vlog(object):
 
         ovs.unixctl.command_register("vlog/reopen", "", 0, 0,
                                      Vlog._unixctl_vlog_reopen, None)
+        ovs.unixctl.command_register("vlog/close", "", 0, 0,
+                                     Vlog._unixctl_vlog_close, None)
         ovs.unixctl.command_register("vlog/set", "spec", 1, sys.maxsize,
                                      Vlog._unixctl_vlog_set, None)
         ovs.unixctl.command_register("vlog/list", "", 0, 0,
@@ -389,6 +391,13 @@ class Vlog(object):
         else:
             conn.reply("Logging to file not configured")
 
+    @staticmethod
+    def _unixctl_vlog_close(conn, unused_argv, unused_aux):
+        if Vlog.__log_file:
+            logger = logging.getLogger("file")
+            logger.removeHandler(Vlog.__file_handler)
+        conn.reply(None)
+
     @staticmethod
     def _unixctl_vlog_set(conn, argv, unused_aux):
         for arg in argv: