Exemple #1
0
def get_screen_handler():
    """
    Get the one and only screen logging handler.

    See launch_config() documentation for screen logging configuration.
    """
    if launch_config.screen_handler is None:
        launch_config.screen_handler = handlers.StreamHandler(sys.stdout)
        launch_config.screen_handler.setFormatter(
            launch_config.screen_formatter)
    return launch_config.screen_handler
Exemple #2
0
    def get_screen_handler(self):
        """
        Get the one and only screen logging handler.

        See launch_config() documentation for screen logging configuration.
        """
        if self.screen_handler is None:
            stream = codecs.StreamWriter(sys.stdout, errors='replace')
            stream.encode = lambda msg, errors='replace': (msg.encode(
                locale.getpreferredencoding(False), errors).decode(
                    locale.getpreferredencoding(False), errors=errors), msg)
            self.screen_handler = handlers.StreamHandler(stream)
            self.screen_handler.setFormatter(self.screen_formatter)
        return self.screen_handler
    def __init__(self,
                 max_backoff=3600,
                 log_level=logging.INFO,
                 silent_backoff=False):
        self.func = None

        self.max_backoff = max_backoff
        self.backoff_time = None
        self.start_time = None

        self.silent_backoff = silent_backoff

        self.logger = logging.getLogger('Backoff')
        self.logger.setLevel(log_level)

        # setup logger to go to syslog, fallback to stderr
        if os.path.exists(SYSLOG_PATH):
            handler = handlers.SysLogHandler(address=SYSLOG_PATH)
        else:
            handler = handlers.StreamHandler()

        self.logger.addHandler(handler)