import logging
import logging.handlers

from obnl.impl import node as _node


def activate_console_logging(log_level=logging.INFO):
    if not hasattr(activate_console_logging, "handler"):
        activate_console_logging.handler = logging.StreamHandler()
        _add_handler(activate_console_logging.handler, log_level)


def activate_file_logging(filename, log_level=logging.INFO):
    if not hasattr(activate_file_logging, "handler"):
        activate_file_logging.handler = logging.handlers.TimedRotatingFileHandler(filename)
        _add_handler(activate_file_logging.handler, log_level)


def _add_handler(handler, log_level):
    handler.setLevel(log_level)
    handler.setFormatter(logging.Formatter(_node.Node.DEFAULT_LOGGING_FORMAT))
    _node.Node.LOGGER.setLevel(1)  # TODO log all data
    _node.Node.LOGGER.addHandler(handler)

@@ -313,24 +313,216 @@
 og_level)%0A%0A%0A
+def deactivate_console_logging():%0A    if hasattr(activate_console_logging, %22handler%22):%0A        _remove_handler(activate_console_logging.handler)%0A        del activate_console_logging.handler%0A%0A%0A
 def activate
@@ -562,32 +562,32 @@
 =logging.INFO):%0A
-
     if not hasat
@@ -777,24 +777,204 @@
 og_level)%0A%0A%0A
+def deactivate_file_logging():%0A    if hasattr(activate_file_logging, %22handler%22):%0A        _remove_handler(activate_file_logging.handler)%0A        del activate_file_logging.handler%0A%0A%0A
 def _add_han
@@ -1199,16 +1199,92 @@
 andler(handler)%0A
+%0A%0Adef _remove_handler(handler):%0A    _node.Node.LOGGER.removeHandler(handler)

add deactivate methods for logging