コード例 #1
0
ファイル: log.py プロジェクト: ccenter/marine-integrations
    def init(self, debug=False):
        """Initialize logging for MI.  Because this is a singleton it will only be initialized once."""
        path = os.environ[LOGGING_CONFIG_ENVIRONMENT_VARIABLE] if LOGGING_CONFIG_ENVIRONMENT_VARIABLE in os.environ else None
        haveenv = path and os.path.isfile(path)
        if path and not haveenv:
            print >> os.stderr, 'WARNING: %s was set but %s was not found (using default configuration files instead)' % (LOGGING_CONFIG_ENVIRONMENT_VARIABLE, path)
        if path and haveenv:
            config.replace_configuration(path)
            if debug:
                print >> sys.stderr, str(os.getpid()) + ' configured logging from ' + path
        elif os.path.isfile(LOGGING_PRIMARY_FROM_FILE):
            config.replace_configuration(LOGGING_PRIMARY_FROM_FILE)
            if debug:
                print >> sys.stderr, str(os.getpid()) + ' configured logging from ' + LOGGING_PRIMARY_FROM_FILE
        else:
            path = pkg_resources.resource_filename('config', LOGGING_PRIMARY_FROM_EGG)
            config.replace_configuration(path)
            if debug:
                print >> sys.stderr, str(os.getpid()) + ' configured logging from ' + path

        if os.path.isfile(LOGGING_MI_OVERRIDE):
            config.add_configuration(LOGGING_MI_OVERRIDE)
            if debug:
                print >> sys.stderr, str(os.getpid()) + ' supplemented logging from ' + LOGGING_MI_OVERRIDE
        elif os.path.isfile(LOGGING_CONTAINER_OVERRIDE):
            config.add_configuration(LOGGING_CONTAINER_OVERRIDE)
            if debug:
                print >> sys.stderr, str(os.getpid()) + ' supplemented logging from ' + LOGGING_CONTAINER_OVERRIDE
コード例 #2
0
ファイル: log.py プロジェクト: n1ywb/mi-instrument
    def init(self, debug=False):
        """Initialize logging for MI.  Because this is a singleton it will only be initialized once."""
        path = os.environ[LOGGING_CONFIG_ENVIRONMENT_VARIABLE] if LOGGING_CONFIG_ENVIRONMENT_VARIABLE in os.environ else None
        haveenv = path and os.path.isfile(path)
        if path and not haveenv:
            print >> os.stderr, 'WARNING: %s was set but %s was not found (using default configuration files instead)' % (LOGGING_CONFIG_ENVIRONMENT_VARIABLE, path)
        if path and haveenv:
            config.replace_configuration(path)
            if debug:
                print >> sys.stderr, str(os.getpid()) + ' configured logging from ' + path
        elif os.path.isfile(LOGGING_PRIMARY_FROM_FILE):
            config.replace_configuration(LOGGING_PRIMARY_FROM_FILE)
            if debug:
                print >> sys.stderr, str(os.getpid()) + ' configured logging from ' + LOGGING_PRIMARY_FROM_FILE
        else:
            logconfig = pkg_resources.resource_string('mi', LOGGING_PRIMARY_FROM_EGG)
            parsed = yaml.load(logconfig)
            config.replace_configuration(parsed)
            if debug:
                print >> sys.stderr, str(os.getpid()) + ' configured logging from config/' + LOGGING_PRIMARY_FROM_FILE

        if os.path.isfile(LOGGING_MI_OVERRIDE):
            config.add_configuration(LOGGING_MI_OVERRIDE)
            if debug:
                print >> sys.stderr, str(os.getpid()) + ' supplemented logging from ' + LOGGING_MI_OVERRIDE
        elif os.path.isfile(LOGGING_CONTAINER_OVERRIDE):
            config.add_configuration(LOGGING_CONTAINER_OVERRIDE)
            if debug:
                print >> sys.stderr, str(os.getpid()) + ' supplemented logging from ' + LOGGING_CONTAINER_OVERRIDE
コード例 #3
0
def main(args=None):
    # Configure logging
    def_log_paths = ['res/config/logging.yml', 'res/config/logging.local.yml']
    for path in def_log_paths:
        try:
            config.add_configuration(path)
        except Exception, e:
            print 'WARNING: could not load logging configuration file %s: %s' % (path, e)
コード例 #4
0
def main(args=None):
    # Configure logging
    def_log_paths = ['res/config/logging.yml', 'res/config/logging.local.yml']
    for path in def_log_paths:
        try:
            config.add_configuration(path)
        except Exception, e:
            print 'WARNING: could not load logging configuration file %s: %s' % (
                path, e)
コード例 #5
0
ファイル: log.py プロジェクト: r-swilderd/mi-instrument
def configure_logging(logging_conf_paths, logging_config_override=None):
    """
    Public call to configure and initialize logging.
    @param logging_conf_paths  List of paths to logging config YML files (in read order)
    @param config_override  Dict with config entries overriding files read
    """
    global logging_was_configured
    logging_was_configured = True

    for path in logging_conf_paths:
        try:
            config.add_configuration(path)
        except Exception, e:
            print 'WARNING: could not load logging configuration file %s: %s' % (path, e)
コード例 #6
0
ファイル: log.py プロジェクト: n1ywb/mi-instrument
def configure_logging(logging_conf_paths, logging_config_override=None):
    """
    Public call to configure and initialize logging.
    @param logging_conf_paths  List of paths to logging config YML files (in read order)
    @param config_override  Dict with config entries overriding files read
    """
    global logging_was_configured
    logging_was_configured = True

    for path in logging_conf_paths:
        try:
            config.add_configuration(path)
        except Exception, e:
            print 'WARNING: could not load logging configuration file %s: %s' % (path, e)
コード例 #7
0
ファイル: log.py プロジェクト: r-swilderd/mi-instrument
    """
    Public call to configure and initialize logging.
    @param logging_conf_paths  List of paths to logging config YML files (in read order)
    @param config_override  Dict with config entries overriding files read
    """
    global logging_was_configured
    logging_was_configured = True

    for path in logging_conf_paths:
        try:
            config.add_configuration(path)
        except Exception, e:
            print 'WARNING: could not load logging configuration file %s: %s' % (path, e)
    if logging_config_override:
        try:
            config.add_configuration(logging_config_override)
        except Exception,e:
            print 'WARNING: failed to apply logging override %r: %e' % (logging_config_override,e)

    # direct warnings mechanism to loggers
    logging.captureWarnings(True)


def is_logging_configured():
    """ allow caller to determine if logging has already been configured in this container """
    global logging_was_configured
    return logging_was_configured or config.get_configuration()



class LoggerManager(Singleton):
コード例 #8
0
ファイル: log.py プロジェクト: r-swilderd/mi-instrument
    Public call to configure and initialize logging.
    @param logging_conf_paths  List of paths to logging config YML files (in read order)
    @param config_override  Dict with config entries overriding files read
    """
    global logging_was_configured
    logging_was_configured = True

    for path in logging_conf_paths:
        try:
            config.add_configuration(path)
        except Exception, e:
            print 'WARNING: could not load logging configuration file %s: %s' % (
                path, e)
    if logging_config_override:
        try:
            config.add_configuration(logging_config_override)
        except Exception, e:
            print 'WARNING: failed to apply logging override %r: %e' % (
                logging_config_override, e)

    # direct warnings mechanism to loggers
    logging.captureWarnings(True)


def is_logging_configured():
    """ allow caller to determine if logging has already been configured in this container """
    global logging_was_configured
    return logging_was_configured or config.get_configuration()


class LoggerManager(Singleton):