def _store_event_data_string(self, event): if isinstance(event, logging.LogRecord): formatter = BBLogFormatter("%(levelname)s: %(message)s") self.event_calls.append(formatter.format(event)) else: self.event_calls.append(bb.event.getName(event)) return
def logger_setup_color(logger, color='auto'): from bb.msg import BBLogFormatter console = logging.StreamHandler(sys.stdout) formatter = BBLogFormatter("%(levelname)s: %(message)s") console.setFormatter(formatter) logger.handlers = [console] if color == 'always' or (color=='auto' and console.stream.isatty()): formatter.enable_color()
def print_ui_queue(): """If we're exiting before a UI has been spawned, display any queued LogRecords to the console.""" logger = logging.getLogger("BitBake") if not _ui_handlers: from bb.msg import BBLogFormatter console = logging.StreamHandler(sys.stdout) console.setFormatter(BBLogFormatter("%(levelname)s: %(message)s")) logger.handlers = [console] while ui_queue: event = ui_queue.pop() if isinstance(event, logging.LogRecord): logger.handle(event)
def print_ui_queue(): global ui_queue """If we're exiting before a UI has been spawned, display any queued LogRecords to the console.""" logger = logging.getLogger("BitBake") if not _uiready: from bb.msg import BBLogFormatter # Flush any existing buffered content sys.stdout.flush() sys.stderr.flush() stdout = logging.StreamHandler(sys.stdout) stderr = logging.StreamHandler(sys.stderr) formatter = BBLogFormatter("%(levelname)s: %(message)s") stdout.setFormatter(formatter) stderr.setFormatter(formatter) # First check to see if we have any proper messages msgprint = False msgerrs = False # Should we print to stderr? for event in ui_queue[:]: if isinstance( event, logging.LogRecord) and event.levelno >= logging.WARNING: msgerrs = True break if msgerrs: logger.addHandler(stderr) else: logger.addHandler(stdout) for event in ui_queue[:]: if isinstance(event, logging.LogRecord): if event.levelno > logging.DEBUG: logger.handle(event) msgprint = True # Nope, so just print all of the messages we have (including debug messages) if not msgprint: for event in ui_queue[:]: if isinstance(event, logging.LogRecord): logger.handle(event) if msgerrs: logger.removeHandler(stderr) else: logger.removeHandler(stdout) ui_queue = []
def print_ui_queue(): """If we're exiting before a UI has been spawned, display any queued LogRecords to the console.""" logger = logging.getLogger("BitBake") if not _ui_handlers: from bb.msg import BBLogFormatter console = logging.StreamHandler(sys.stdout) console.setFormatter(BBLogFormatter("%(levelname)s: %(message)s")) logger.handlers = [console] # First check to see if we have any proper messages msgprint = False for event in ui_queue: if isinstance(event, logging.LogRecord): if event.levelno > logging.DEBUG: logger.handle(event) msgprint = True if msgprint: return # Nope, so just print all of the messages we have (including debug messages) for event in ui_queue: if isinstance(event, logging.LogRecord): logger.handle(event)