Configure sentry.errors to use the same loggers as the root handler
        @rtype: None
193810
def configure_sentry_errors(self):
        
        sentry_errors_logger = logging.getLogger('sentry.errors')
        root_logger = logging.getLogger()
        for handler in root_logger.handlers:
            sentry_errors_logger.addHandler(handler)
881287
def setup_logging(self):
        """"""
        date_format = '%Y-%m-%dT%H:%M:%S'
        log_format = '%(asctime)s %(levelname)s: %(message)s'

        if self.opts.verbose:
            lvl = logging.DEBUG
        else:
            lvl = logging.INFO
            # Requests is a bit chatty
            logging.getLogger('requests').setLevel('WARNING')

        self.logger.setLevel(lvl)

        stdout = logging.StreamHandler(sys.stdout)
        stdout.setLevel(lvl)
        formatter = logging.Formatter(log_format, date_format)
        stdout.setFormatter(formatter)
        self.logger.addHandler(stdout)

        # Decided not to use stderr
        # stderr = logging.StreamHandler(sys.stderr)
        # stderr.setLevel(logging.ERROR)  # Error and above go to both stdout & stderr
        # formatter = logging.Formatter(log_format, date_format)
        # stderr.setFormatter(formatter)
        # self.logger.addHandler(stderr)

        log = self.opts.log or self.config['crony'].get('log_file')
        if log:
            logfile = logging.FileHandler(log)
            logfile.setLevel(lvl)
            formatter = logging.Formatter(log_format, date_format)
            logfile.setFormatter(formatter)
            self.logger.addHandler(logfile)

        if self.sentry_client:
            sentry = SentryHandler(self.sentry_client)
            sentry.setLevel(logging.ERROR)
            self.logger.addHandler(sentry)

        self.logger.debug('Logging setup complete.')
532589
function setupHandlers() {

    function terminate(err) {
        util.log('Uncaught Error: ' + err.message);
        console.log(err.stack);
        if (proc.shutdownHook) {
            proc.shutdownHook(err, gracefulShutdown);
        }
    }

    process.on('uncaughtException', terminate);

    process.addListener('SIGINT', gracefulShutdown);

    process.addListener('SIGHUP', function () {
        util.log('RECIEVED SIGHUP signal, reloading log files...');
        reload(argv);
    });

}
734120
def init_log_config(handler=None):
    
    for applog in lognames.values():
        # propagate except for root app logger 'linkcheck'
        propagate = (applog != LOG_ROOT)
        configdict['loggers'][applog] = dict(level='INFO', propagate=propagate)

    logging.config.dictConfig(configdict)
    if handler is None:
        handler = ansicolor.ColoredStreamHandler(strm=sys.stderr)
    add_loghandler(handler)
353836
def setup_logging(config_path=None, log_level=logging.INFO,
                  formatter='standard'):
    

    config = {
        'version': 1,
        'disable_existing_loggers': False,
        'formatters': {
            'standard': {
                'format':
                    '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
            },
            'ui': {
                'format':
                    '[%(levelname)s] %(message)s'
            }
        },
        'handlers': {
            'console': {
                'class': 'logging.StreamHandler',
                'level': log_level,
                'formatter': formatter,
                'stream': 'ext://sys.stdout'
            },
        },
        'loggers': {
            '': {
                'handlers': ['console'],
                'level': log_level,
                'propagate': True
            },
            'yapsy': {
                'handlers': ['console'],
                'level': logging.INFO
            }
        }
    }

    if config_path:
        if os.path.exists(config_path):
            with open(config_path, 'rt') as f:
                config = yaml.safe_load(f.read())
        else:
            print('Specified path does not exist: {}, '
                  'using default config'.format(config_path))

    logging.config.dictConfig(config)
1014026
def setup_logging(args):
    
    handler = logging.StreamHandler()
    handler.setLevel(args.log_level)
    formatter = logging.Formatter(('%(asctime)s - '
                                   '%(name)s - '
                                   '%(levelname)s - '
                                   '%(message)s'))
    handler.setFormatter(formatter)
    LOGGER.addHandler(handler)
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))
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
303308
def add_log_handler(log, handler=None, debug=None, fmt=None):
    
    if debug:
        log.setLevel(debug)
    if handler:
        # if not fmt:
        #     fmt = __LOG_FMT
        if fmt:
            handler.setFormatter(fmt)
        log.addHandler(handler)
982001
def configureLogger(logFolder, logFile):
    '''  '''
    # Set debug level
    logLevel = 'DEBUG'
    logger = logging.getLogger()
    logger.setLevel(logLevel)

    # Format
    formatter = logging.Formatter('%(asctime)s - %(levelname)s | %(name)s -> %(message)s', '%Y-%m-%d %H:%M:%S')

    # Remove default handler to keep only clean one
    for hdlr in logger.handlers:
        logger.removeHandler(hdlr)

    # Create missing folder if needed
    if not os.path.exists(logFolder):
        os.makedirs(logFolder, 0700)

    #
    # ----------------------------
    #   CREATE CONSOLE HANDLER
    # ----------------------------
    #

    # Create console handler
    consoleh = logging.StreamHandler()
    consoleh.setLevel(logLevel)
    consoleh.setFormatter(formatter)

    # Set our custom handler
    logger.addHandler(consoleh)

    #
    # ----------------------------
    #   CREATE FILE HANDLER
    # ----------------------------
    #
    fileh = logging.FileHandler(logFile, 'a')
    fileh.setLevel(logLevel)
    fileh.setFormatter(formatter)

    # Set our custom handler
    logger.addHandler(fileh)
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
1082616
def logger_init(level):
    
    levellist = [logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG]
    handler = logging.StreamHandler()
    fmt = ('%(levelname) -10s %(asctime)s %(name) -30s %(funcName) '
           '-35s %(lineno) -5d: %(message)s')
    handler.setFormatter(logging.Formatter(fmt))
    logger = logging.root
    logger.addHandler(handler)
    logger.setLevel(levellist[level])
1191082
def install_handler(self, app):
        """"""
        from raven.contrib.celery import register_logger_signal, \
            register_signal
        from raven.contrib.flask import Sentry, make_client
        from raven.handlers.logging import SentryHandler

        # Installs sentry in app.extensions['sentry']
        level = getattr(logging, app.config['LOGGING_SENTRY_LEVEL'])

        # Get the Sentry class.
        cls = app.config['LOGGING_SENTRY_CLASS']
        if cls:
            if isinstance(cls, six.string_types):
                cls = import_string(cls)
        else:
            cls = Sentry

        sentry = cls(
            app,
            logging=True,
            level=level
        )

        app.logger.addHandler(SentryHandler(client=sentry.client, level=level))

        # Capture warnings from warnings module
        if app.config['LOGGING_SENTRY_PYWARNINGS']:
            self.capture_pywarnings(
                SentryHandler(sentry.client))

        # Setup Celery logging to Sentry
        if app.config['LOGGING_SENTRY_CELERY']:
            try:
                register_logger_signal(sentry.client, loglevel=level)
            except TypeError:
                # Compatibility mode for Raven<=5.1.0
                register_logger_signal(sentry.client)
            register_signal(sentry.client)

        # Werkzeug only adds a stream handler if there's no other handlers
        # defined, so when Sentry adds a log handler no output is
        # received from Werkzeug unless we install a console handler
        # here on the werkzeug logger.
        if app.debug:
            logger = logging.getLogger('werkzeug')
            logger.setLevel(logging.INFO)
            logger.addHandler(logging.StreamHandler())
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__)
524131
def install_handler(self, app):
        """"""
        # Check if directory exists.
        basedir = dirname(app.config['LOGGING_FS_LOGFILE'])
        if not exists(basedir):
            raise ValueError(
                'Log directory {0} does not exists.'.format(basedir))

        handler = RotatingFileHandler(
            app.config['LOGGING_FS_LOGFILE'],
            backupCount=app.config['LOGGING_FS_BACKUPCOUNT'],
            maxBytes=app.config['LOGGING_FS_MAXBYTES'],
            delay=True,
        )
        handler.setFormatter(logging.Formatter(
            '%(asctime)s %(levelname)s: %(message)s '
            '[in %(pathname)s:%(lineno)d]'
        ))
        handler.setLevel(app.config['LOGGING_FS_LEVEL'])

        # Add handler to application logger
        app.logger.addHandler(handler)

        if app.config['LOGGING_FS_PYWARNINGS']:
            self.capture_pywarnings(handler)

        # Add request_id to log record
        app.logger.addFilter(add_request_id_filter)
663484
def setup_logger():  # type: () -> logging.Logger
    
    formatter = logging.Formatter(
        fmt='%(levelname)s - %(module)s - %(message)s')

    handler = logging.StreamHandler()
    handler.setFormatter(formatter)

    logger = logging.getLogger()
    logger.setLevel(logging.DEBUG)
    logger.addHandler(handler)
    return logger
894209
def setup_logging():
    
    fmt = 'DBG<0>%(pathname)s:%(lineno)d  %(funcName)s: %(message)s'

    handler_stderr = logging.StreamHandler(sys.stderr)
    handler_stderr.setFormatter(logging.Formatter(fmt))
    if OPTIONS['--verbose'] == 1:
        handler_stderr.addFilter(logging.Filter(__name__))

    root_logger = logging.getLogger()
    root_logger.setLevel(logging.DEBUG)
    root_logger.addHandler(handler_stderr)