示例#1
0
def logging_done():
    """Close all logging file descriptors"""

    for handler in root_logger.handlers[:]:
        debug("close logging handler: %s" % handler)
        handler.close()
        root_logger.removeHandler(handler)
示例#2
0
文件: utils.py 项目: cloudera/hue
 def setUp(self):
     """Make a fresh logger for each test function"""
     super(LoggingMixin, self).setUp()
     named = getLogger(self.log_name)
     for handler in root.handlers[:]:
         root.removeHandler(handler)
     for handler in named.handlers[:]:
         named.removeHandler(handler)
     self.log_handler = LoggingRecorder(level='DEBUG')
     named.addHandler(self.log_handler)
示例#3
0
 def setUp(self):
     """Make a fresh logger for each test function"""
     super(LoggingMixin, self).setUp()
     named = getLogger(self.log_name)
     for handler in root.handlers[:]:
         root.removeHandler(handler)
     for handler in named.handlers[:]:
         named.removeHandler(handler)
     self.log_handler = LoggingRecorder(level='DEBUG')
     named.addHandler(self.log_handler)
示例#4
0
 def toggle_debug(self):
     #Once remove all the handlers
     for handler in root.handlers[:]:
         root.removeHandler(handler)
     if self.btn_debug.isChecked():
         print("!!!")
         basicConfig(
             level=DEBUG,
             #filename='log.txt',
             format="%(asctime)s %(levelname)s %(message)s")
     else:
         basicConfig(level=WARN,
                     format="%(asctime)s %(levelname)s %(message)s")
示例#5
0
def log_collection_context(logging_memory_handler, tempdir, prefix, timestamp, output_path=None, creation_dir=None):
    from logging import root, DEBUG
    path = get_tar_path(prefix, output_path, timestamp, creation_dir)
    root.addHandler(logging_memory_handler)
    root.setLevel(DEBUG)
    try:
        yield path
    finally:
        with open_archive(path) as archive:
            root.removeHandler(logging_memory_handler)
            logging_memory_handler.flush()
            logging_memory_handler.close()
            add_directory(archive, tempdir)
            print("Logs collected successfully to {}".format(path))
示例#6
0
def log_collection_context(logging_memory_handler,
                           tempdir,
                           prefix,
                           timestamp,
                           output_path=None,
                           creation_dir=None):
    from logging import root, DEBUG
    path = get_tar_path(prefix, output_path, timestamp, creation_dir)
    root.addHandler(logging_memory_handler)
    root.setLevel(DEBUG)
    try:
        yield path
    finally:
        with open_archive(path) as archive:
            root.removeHandler(logging_memory_handler)
            logging_memory_handler.flush()
            logging_memory_handler.close()
            add_directory(archive, tempdir)
            print("Logs collected successfully to {}".format(path))
示例#7
0
def reset_settings():
    for handler in root.handlers:
        root.removeHandler(handler)
示例#8
0
 def setUpClass(cls):
     for handler in root.handlers[:]:
         root.removeHandler(handler)
     cls.temp_stdout = sys.stdout
     sys.stdout = StringIO()