Create a fully configured CloudLoggingHandler.

        Returns:
            (obj): Instance of `google.cloud.logging.handlers.
                                CloudLoggingHandler`
553097
def get_handler(self):
        

        gcl_client = gcl_logging.Client(
            project=self.project_id, credentials=self.credentials)
        handler = gcl_handlers.CloudLoggingHandler(
            gcl_client,
            resource=self.resource,
            labels={
                'resource_id': self.instance_id,
                'resource_project': self.project_id,
                'resource_zone': self.zone,
                'resource_host': self.hostname
            })
        handler.setFormatter(self.get_formatter())
        self._set_worker_thread_level()
        return handler
52217
def _create_logger(name='did', level=None):
        
        # Create logger, handler and formatter
        logger = logging.getLogger(name)
        handler = logging.StreamHandler()
        handler.setFormatter(Logging.ColoredFormatter())
        logger.addHandler(handler)
        # Save log levels in the logger itself (backward compatibility)
        for level in Logging.LEVELS:
            setattr(logger, level, getattr(logging, level))
        # Additional logging constants and methods for details and data
        logger.DATA = LOG_DATA
        logger.DETAILS = LOG_DETAILS
        logger.ALL = LOG_ALL
        logger.details = lambda message: logger.log(
            LOG_DETAILS, message) # NOQA
        logger.data = lambda message: logger.log(
            LOG_DATA, message) # NOQA
        logger.all = lambda message: logger.log(
            LOG_ALL, message) # NOQA
        return logger
788629
def _configure_logger_handler(cls, log_dest, log_filename):
        

        if log_dest is None:
            return None

        msg_format = '%(asctime)s-%(name)s-%(message)s'

        if log_dest == 'stderr':
            # Note: sys.stderr is the default stream for StreamHandler
            handler = logging.StreamHandler()
            handler.setFormatter(logging.Formatter(msg_format))
        elif log_dest == 'file':
            if not log_filename:
                raise ValueError("Log filename is required if log destination "
                                 "is 'file'")
            handler = logging.FileHandler(log_filename, encoding="UTF-8")
            handler.setFormatter(logging.Formatter(msg_format))
        else:
            raise ValueError(
                _format("Invalid log destination: {0!A}; Must be one of: "
                        "{1!A}", log_dest, LOG_DESTINATIONS))

        return handler
1046859
def create_logger(app: 'Quart') -> Logger:
    
    logger = getLogger('quart.app')

    if app.debug and logger.level == NOTSET:
        logger.setLevel(DEBUG)

    logger.addHandler(default_handler)
    return logger
306080
def setup_extended_logging(opts):
    '''
    
    '''
    if is_extended_logging_configured() is True:
        # Don't re-configure external loggers
        return

    # Explicit late import of salt's loader
    import salt.loader

    # Let's keep a reference to the current logging handlers
    initial_handlers = logging.root.handlers[:]

    # Load any additional logging handlers
    providers = salt.loader.log_handlers(opts)

    # Let's keep track of the new logging handlers so we can sync the stored
    # log records with them
    additional_handlers = []

    for name, get_handlers_func in six.iteritems(providers):
        logging.getLogger(__name__).info('Processing `log_handlers.%s`', name)
        # Keep a reference to the logging handlers count before getting the
        # possible additional ones.
        initial_handlers_count = len(logging.root.handlers)

        handlers = get_handlers_func()
        if isinstance(handlers, types.GeneratorType):
            handlers = list(handlers)
        elif handlers is False or handlers == [False]:
            # A false return value means not configuring any logging handler on
            # purpose
            logging.getLogger(__name__).info(
                'The `log_handlers.%s.setup_handlers()` function returned '
                '`False` which means no logging handler was configured on '
                'purpose. Continuing...', name
            )
            continue
        else:
            # Make sure we have an iterable
            handlers = [handlers]

        for handler in handlers:
            if not handler and \
                    len(logging.root.handlers) == initial_handlers_count:
                logging.getLogger(__name__).info(
                    'The `log_handlers.%s`, did not return any handlers '
                    'and the global handlers count did not increase. This '
                    'could be a sign of `log_handlers.%s` not working as '
                    'supposed', name, name
                )
                continue

            logging.getLogger(__name__).debug(
                'Adding the \'%s\' provided logging handler: \'%s\'',
                name, handler
            )
            additional_handlers.append(handler)
            logging.root.addHandler(handler)

    for handler in logging.root.handlers:
        if handler in initial_handlers:
            continue
        additional_handlers.append(handler)

    # Sync the null logging handler messages with the temporary handler
    if LOGGING_STORE_HANDLER is not None:
        LOGGING_STORE_HANDLER.sync_with_handlers(additional_handlers)
    else:
        logging.getLogger(__name__).debug(
            'LOGGING_STORE_HANDLER is already None, can\'t sync messages '
            'with it'
        )

    # Remove the temporary queue logging handler
    __remove_queue_logging_handler()

    # Remove the temporary null logging handler (if it exists)
    __remove_null_logging_handler()

    global __EXTERNAL_LOGGERS_CONFIGURED
    __EXTERNAL_LOGGERS_CONFIGURED = True
1278008
def init_logger():
    
    import logging as _logging
    import logging.config

    # Package level logger
    _logging.config.dictConfig({
        'version': 1,
        'disable_existing_loggers': False,
        'formatters': {
            'standard': {
                'format': '%(asctime)s [%(levelname)s] %(name)s, %(lineno)s: %(message)s'
            },
            'brief': {
                'format': '[%(levelname)s] %(name)s: %(message)s'
            }
        },
        'handlers': {
            'default': {
                'class': 'logging.StreamHandler',
                'formatter': 'brief'
            },
            'file': {
                'class': 'logging.FileHandler',
                'formatter': 'standard',
                'filename': _client_log_file,
                'encoding': 'UTF-8',
                'delay': 'False',
            }
        },
        'loggers': {
            _root_package_name: {
                'handlers': ['default', 'file'],
                'propagate': 'True'
            }
        }
    })

    # Set module specific log levels
    _logging.getLogger('requests').setLevel(_logging.CRITICAL)
    if _i_am_a_lambda_worker():
        _logging.getLogger(_root_package_name).setLevel(_logging.WARNING)
    else:
        _logging.getLogger(_root_package_name).setLevel(_logging.INFO)
1172724
def configured_logger(name=None, config=None, level=None, handlers=None):
    '''
    '''
    name = name or ''
    with process_global('lock'):
        logconfig = process_global('_config_logging')
        # if the logger was not configured, do so.
        if not logconfig:
            logconfig = deepcopy(config or LOGGING_CONFIG)
            logconfig['configured'] = set()
            process_global('_config_logging', logconfig, True)
        else:
            configured = logconfig.get('configured')
            if name in configured:
                return logging.getLogger(name)

        level = get_level(level)
        # No loggers configured. This means no logconfig setting
        # parameter was used. Set up the root logger with default
        # loggers
        if level == logging.NOTSET:
            handlers = ['silent']

        level = logging.getLevelName(level)
        cfg = {'level': level, 'propagate': False}
        if handlers:
            cfg['handlers'] = handlers

        config = copy(logconfig)
        configured = config.pop('configured')
        configured.add(name)

        if name:
            config.pop('root', None)
            loggers = config.pop('logger', {})
            if name in loggers:
                loggers[name].update(cfg)
                cfg = loggers[name]
            config['loggers'] = {name: cfg}
        else:
            if 'root' in config:
                config['root'].update(cfg)
                cfg = config['root']
            if 'handlers' not in cfg:
                cfg['handlers'] = ['console']
            config['root'] = cfg
        #
        dictConfig(config)
        return logging.getLogger(name)
320363
protected function createLogHandlers() {
        $logHandlers = $this->configuredLogHandlers;
                      
        foreach ($logHandlers as $handlerNamespace => $handlerDetails) {
            if (
                is_array($handlerDetails)
                && array_key_exists('handler_parameters', $handlerDetails)
            ) {
                $handlerParameters = $handlerDetails['handler_parameters'];
                $handlerObj = new $handlerNamespace(...$handlerParameters);
                $this->concreteLogger->pushHandler($handlerObj);
            }
        }
    }
1062417
def make_logger(scraper):
    

    logger = logging.getLogger('')
    logger.setLevel(logging.DEBUG)

    requests_log = logging.getLogger("requests")
    requests_log.setLevel(logging.WARNING)

    json_handler = logging.FileHandler(log_path(scraper))
    json_handler.setLevel(logging.DEBUG)
    json_formatter = jsonlogger.JsonFormatter(make_json_format())
    json_handler.setFormatter(json_formatter)
    logger.addHandler(json_handler)

    console_handler = logging.StreamHandler()
    console_handler.setLevel(logging.INFO)
    fmt = '%(name)s [%(levelname)-8s]: %(message)s'
    formatter = logging.Formatter(fmt)
    console_handler.setFormatter(formatter)
    logger.addHandler(console_handler)

    logger = logging.getLogger(scraper.name)
    logger = TaskAdapter(logger, scraper)
    return logger
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)
1147927
def reconfigure_log_level(self):
        
        if Global.LOGGER:
            Global.LOGGER.debug('reconfiguring logger level')
        stream_handlers = filter(lambda x: type(x) is logging.StreamHandler,
                                 self._logger_instance.handlers)

        for x in stream_handlers:
            x.level = Global.CONFIG_MANAGER.log_level

        return self.get_logger()
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))
1260010
def setup_logger(logger=None, level='INFO'):
    
    if not logger:  # if no logger exists, make one
        logger = logging.getLogger()

    if not logger.handlers:  # setup logger handlers
        channel = logging.StreamHandler()
        channel.setFormatter(log.DebugLogFormatter())

        # channel.setFormatter(log.LogFormatter())
        logger.setLevel(level)
        logger.addHandler(channel)
746832
def make_stream_handler(graph, formatter):
    
    return {
        "class": graph.config.logging.stream_handler.class_,
        "formatter": formatter,
        "level": graph.config.logging.level,
        "stream": graph.config.logging.stream_handler.stream,
    }
545228
def setup_logger(log_dir=None, loglevel=logging.DEBUG):
    

    create_home_dir()
    create_dir(os.path.join(get_default_home_dir(), 'log'))

    if log_dir is None:
        log_dir = os.path.join(get_default_home_dir(), 'log')

    logger = logging.getLogger('ding0') # use filename as name in log
    logger.setLevel(loglevel)

    # create a file handler
    handler = logging.FileHandler(os.path.join(log_dir, 'ding0.log'))
    handler.setLevel(logging.DEBUG)
    formatter = logging.Formatter(
        '%(asctime)s-%(funcName)s-%(message)s (%(levelname)s)')
    handler.setFormatter(formatter)

    # create a stream handler (print to prompt)
    stream = logging.StreamHandler()
    stream.setLevel(logging.INFO)
    stream_formatter = logging.Formatter(
        '%(message)s (%(levelname)s)')
    stream.setFormatter(stream_formatter)

    # add the handlers to the logger
    logger.addHandler(handler)
    logger.addHandler(stream)

    logger.info('########## New run of Ding0 issued #############')

    return logger
1102006
def get_logger(name=None, level=None, stream=DEFAULT_STREAM,
               clobber_root_handler=True, logger_factory=None,
               wrapper_class=None):
    """"""
    _configure_logger(
        logger_factory=logger_factory,
        wrapper_class=wrapper_class)
    log = structlog.get_logger(name)
    root_logger = logging.root
    if log == root_logger:
        if not _has_streamhandler(root_logger, level=level, stream=stream):
            stream_handler = logging.StreamHandler(stream)
            stream_handler.setLevel(level)
            stream_handler.setFormatter(logging.Formatter(fmt=LOG_FORMAT))
            root_logger.addHandler(stream_handler)
        else:
            if clobber_root_handler:
                for handler in root_logger.handlers:
                    handler.setFormatter(logging.Formatter(fmt=LOG_FORMAT))
    if level:
        log.setLevel(level)
    return log
974334
def add_logging_handler(handler, format_='file'):
    
    global __UTOOL_ROOT_LOGGER__
    if __UTOOL_ROOT_LOGGER__ is None:
        builtins.print('[WARNING] logger not started, cannot add handler')
        return
    # create formatter and add it to the handlers
    #logformat = '%Y-%m-%d %H:%M:%S'
    #logformat = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
    timeformat = '%H:%M:%S'
    if format_ == 'file':
        logformat = '[%(asctime)s]%(message)s'
    elif format_ == 'stdout':
        logformat = '%(message)s'
    else:
        raise AssertionError('unknown logging format_: %r' % format_)
    # Create formatter for handlers
    formatter = logging.Formatter(logformat, timeformat)
    handler.setLevel(logging.DEBUG)
    handler.setFormatter(formatter)
    __UTOOL_ROOT_LOGGER__.addHandler(handler)