Utility function to setup the logging systems based on the `logging.json` configuration file
437113
def setup_logging():
    """"""
    config = json.load(open(os.path.join(config_path, 'logging.json')))

    # If syslogging is disabled, set the pipeline handler to NullHandler
    if dbconfig.get('enable_syslog_forwarding', NS_LOG, False):
        try:
            config['formatters']['syslog'] = {
                'format': _get_syslog_format('cloud-inquisitor-logs')
            }

            config['handlers']['syslog'] = {
                'class': 'cloud_inquisitor.log.SyslogPipelineHandler',
                'formatter': 'syslog',
                'filters': ['standard']
            }

            config['loggers']['cloud_inquisitor']['handlers'].append('syslog')

            # Configure the audit log handler
            audit_handler = SyslogPipelineHandler()
            audit_handler.setFormatter(logging.Formatter(_get_syslog_format('cloud-inquisitor-audit')))
            audit_handler.setLevel(logging.DEBUG)

            _AUDIT_LOGGER.addHandler(audit_handler)
            _AUDIT_LOGGER.propagate = False
        except Exception as ex:
            print('An error occured while configuring the syslogger: {}'.format(ex))

    logging.config.dictConfig(config)
480053
def setup_logging(filename, log_dir=None, force_setup=False):
    ''' 
    '''
    if not force_setup and ChirpCLI.SETUP_COMPLETED:
        logging.debug("Master logging has been setup. This call will be ignored.")
        return
    if log_dir and not os.path.exists(log_dir):
        os.makedirs(log_dir)
    if os.path.isfile(filename):
        with open(filename) as config_file:
            try:
                config = json.load(config_file)
                logging.config.dictConfig(config)
                logging.info("logging was setup using {}".format(filename))
                ChirpCLI.SETUP_COMPLETED = True
            except Exception as e:
                logging.exception("Could not load logging config")
                # default logging config
                logging.basicConfig(level=logging.INFO)
    else:
        logging.basicConfig(level=logging.INFO)
707851
def setup_logging(fail_silently=False):
    
    config = None

    paths = list(get_config_paths(filename='logconfig.yml', reversed=True))
    for path in paths:
        if not os.path.exists(path):
            continue

        with open(path, 'rt') as f:
            config = yaml.safe_load(f.read())

        LOG_LEVEL = os.environ.get('LOG_LEVEL')
        if LOG_LEVEL:
            config['root']['level'] = LOG_LEVEL.upper()
            config['handlers']['console']['level'] = LOG_LEVEL.upper()

        logging.config.dictConfig(config)

        break
    else:
        if not fail_silently:
            raise LogconfigError('Unable to find logconfig in {}'.format(paths))

    return config
360036
def configure_logging(conf):
    """"""
    root_logger = logging.getLogger()
    root_logger.setLevel(getattr(logging, conf.loglevel.upper()))
    if conf.logtostderr:
        add_stream_handler(root_logger, sys.stderr)
    if conf.logtostdout:
        add_stream_handler(root_logger, sys.stdout)
1002525
def configure_logging(level=logging.DEBUG):
    """"""
    if level == logging.DEBUG:
        # For debugging purposes, log from everyone!
        logging.basicConfig(
            level=logging.DEBUG,
            format='%(asctime)s - %(levelname)s - %(message)s'
        )
        return logging

    logger = logging.getLogger(__name__)
    logger.setLevel(level)
    formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
    ch = logging.StreamHandler()
    ch.setLevel(level)
    ch.setFormatter(formatter)
    logger.addHandler(ch)
    return logger
1315545
def log_setup(debug_bool):
    

    level = logging.DEBUG if debug_bool else logging.INFO

    logging.config.dictConfig(
        {
            "version": 1,
            "disable_existing_loggers": False,
            "formatters": {
                "verbose": {
                    "format": "%(asctime)s %(levelname)-8s %(name)s %(module)s "
                    "%(process)d %(thread)d %(message)s",
                    "datefmt": "%Y-%m-%d %H:%M:%S",
                }
            },
            "handlers": {
                "console": {
                    "class": "logging.StreamHandler",
                    "formatter": "verbose",
                    "level": level,
                    "stream": "ext://sys.stdout",
                }
            },
            "loggers": {
                "": {
                    "handlers": ["console"],
                    "level": level,
                    "class": "logging.StreamHandler",
                }
            },
        }
    )
50869
def setup_logging(self):
        
        if self.config.debug:
            util.setup_logging(level=logging.DEBUG)
            util.activate_debug_shell_on_signal()
        else:
            util.setup_logging(level=logging.INFO)
166091
def _setup_logging(self):
        
        self._log_level_delta = (self._args.quiet * 10) - (self._args.verbose * 10)
        level = max(1, self._default_log_level + self._log_level_delta)
        logging.basicConfig(level=level, format=LOG_FORMAT)
183831
def configure_logging(args):
    """"""
    log_format = logging.Formatter('%(levelname)s:%(name)s:line %(lineno)s:%(message)s')
    log_level = logging.INFO if args.verbose else logging.WARN
    log_level = logging.DEBUG if args.debug else log_level
    console = logging.StreamHandler()
    console.setFormatter(log_format)
    console.setLevel(log_level)
    root_logger = logging.getLogger()
    if len(root_logger.handlers) == 0:
        root_logger.addHandler(console)
    root_logger.setLevel(log_level)
    root_logger.handlers[0].setFormatter(log_format)
    logging.getLogger(__name__)
346146
def _set_application_logger(self):
        
        formatter = None
        if self._formatter == "json":
            if hasattr(self._config, "formatString"):
                formatter = CustomJsonFormatter(self._config.formatString)
            else:
                formatter = CustomJsonFormatter(self.default_json_fmt)
        else:
            if hasattr(self._config, "formatString"):
                formatter = logging.Formatter(self._config.formatString)
            else:
                formatter = logging.Formatter(self.default_txt_fmt)

        # get logging.Logger instance and set formatter
        self.logger = logging.getLogger('CloeePyApplication')
        logHandler = logging.StreamHandler()
        logHandler.setFormatter(formatter)
        self.logger.addHandler(logHandler)
        self.logger.setLevel(self._log_level)
1305681
def setup_logging(logging_config, debug=False):
    """"""

    if logging_config is not None:
        logging.config.fileConfig(logging_config)

    else:
        logging.basicConfig(level=debug and logging.DEBUG or logging.ERROR)
569932
def setup_logging():
    
    global console_handler

    # make sure logging is setup only once
    if console_handler:
        return

    # set the handler of the law root logger
    console_handler = logging.StreamHandler()
    console_handler.setFormatter(LogFormatter())
    logging.getLogger("law").addHandler(console_handler)

    # set levels for all loggers
    for name, level in Config.instance().items("logging"):
        level = level.upper()
        if hasattr(logging, level):
            logger = logging.getLogger(name)
            logger.setLevel(getattr(logging, level))
            logger.debug("registered logger with level '{}'".format(level))
122786
def configureLogger(self):
        
        baseLogLevel = logging.DEBUG if self.isDebugLogging() else logging.INFO
        # create recorder app root logger
        logger = logging.getLogger(self._name)
        logger.setLevel(baseLogLevel)
        # file handler
        fh = handlers.RotatingFileHandler(path.join(self._getConfigPath(), self._name + '.log'),
                                          maxBytes=10 * 1024 * 1024, backupCount=10)
        fh.setLevel(baseLogLevel)
        # create console handler with a higher log level
        ch = logging.StreamHandler()
        ch.setLevel(logging.WARN)
        # create formatter and add it to the handlers
        formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(funcName)s - %(message)s')
        fh.setFormatter(formatter)
        ch.setFormatter(formatter)
        # add the handlers to the logger
        logger.addHandler(fh)
        logger.addHandler(ch)
        return logger
832627
def setup_logging(config=None):
    """"""
    # TODO: integrate in general config file
    print(__name__)
    if config and config.get('logging'):
        logging.config.dictConfig(config.get('logging'))
    else:
        logging.basicConfig(format='%(asctime)s %(levelname)s:%(message)s',
                            level=logging.DEBUG)
1332035
def setup_main_logger(file_logging=True, console=True, path: Optional[str] = None, level=logging.INFO):
    
    if file_logging and console:
        log_config = LOGGING_CONFIGS["file_console"]  # type: ignore
    elif file_logging:
        log_config = LOGGING_CONFIGS["file_only"]
    elif console:
        log_config = LOGGING_CONFIGS["console_only"]
    else:
        log_config = LOGGING_CONFIGS["none"]

    if path:
        log_config["handlers"]["rotating"]["filename"] = path  # type: ignore

    for _, handler_config in log_config['handlers'].items():  # type: ignore
        handler_config['level'] = level

    logging.config.dictConfig(log_config)  # type: ignore

    def exception_hook(exc_type, exc_value, exc_traceback):
        if is_python34():
            # Python3.4 does not seem to handle logger.exception() well
            import traceback
            traceback = "".join(traceback.format_tb(exc_traceback)) + exc_type.name
            logging.error("Uncaught exception\n%s", traceback)
        else:
            logging.exception("Uncaught exception", exc_info=(exc_type, exc_value, exc_traceback))

    sys.excepthook = exception_hook
1066890
def setupLogFile(self):
		""""""
		self.logWrite("\n###############################################")
		self.logWrite("calcpkg.py log from " + str(datetime.datetime.now()))
		self.changeLogging(True)
75341
def setup_logger(
    base_name,
    root_dir=None,
    enable_json=True,
    json_formatter='tipsi_tools.tipsi_logging.JSFormatter',
    loggers={},
):
    
    if not root_dir:
        root_dir = os.environ.get('LOG_DIR')
    assert root_dir, 'You should pass root_dir parameter or set env LOG_DIR'

    JSON_FORMATTER = {
        '()': json_formatter,
        'env_vars': ['HOST_TYPE', 'TIPSI_CONFIG', 'TIPSI_BRANCH', 'CONTAINER_TYPE'],
    }

    default_loggers = {
        '': {'handlers': ['default'], 'level': 'DEBUG', 'propagate': True},
        'googleapicliet.discovery_cache': {'level': 'ERROR'},
        'boto3': {'level': 'INFO'},
        'botocore': {'level': 'INFO'},
        'kazoo': {'level': 'INFO'},
        'urllib3': {'level': 'INFO'},
    }

    LOGGING = {
        'version': 1,
        'disable_existing_loggers': False,
        'formatters': {
            'json': JSON_FORMATTER,
            'standard': {'format': '%(asctime)s [%(levelname)s] %(name)s: %(message)s'},
        },
        'handlers': {'default': base_handler(get_plain_logname(base_name, root_dir, enable_json))},
        'loggers': {**default_loggers, **loggers},
    }
    if enable_json:
        LOGGING['handlers']['json'] = base_handler(
            os.path.join(root_dir, '{}.json_log'.format(base_name)), formatter='json'
        )
        LOGGING['loggers']['']['handlers'].append('json')
    logging.config.dictConfig(LOGGING)