Create a `showwarning` function that uses the given logger.

    Arguments:
        logger (~logging.Logger): the logger to use.

    Returns:
        function: a function that can be used as the `warnings.showwarning`
            callback.
177301
def warn_logging(logger):
    # type: (logging.Logger) -> Callable
    
    def showwarning(message, category, filename, lineno, file=None, line=None):
        logger.warning(message)
    return showwarning
384082
def get_logger(name):
    
    logger = logging.getLogger(name)
    logger.addHandler(logging.NullHandler())
    return logger
1238209
def init_logging(verbose=False, format='%(asctime)s %(message)s'):
    
    def sig_handler(signum, frame):
        logger = logging.getLogger()
        log_level = logger.level
        if log_level == logging.DEBUG:
            log_level = logging.WARN
        else:
            log_level = logging.DEBUG
        logging.warn('Got signal %d, setting log level to %d',
                     signum, log_level)
        logger.setLevel(log_level)

    signal.signal(signal.SIGUSR1, sig_handler)

    if verbose:
        initial_level = logging.DEBUG
    else:
        initial_level = logging.WARN
    logging.getLogger().setLevel(initial_level)
    logging.basicConfig(format=format, level=initial_level)
658082
function createLogger(fn) {
	return function () {
		var args = [],
			self = this,
			c;
		for (c = 0; c < arguments.length; c++) {
			args[c] = logger.specialObjectClone(arguments[c]);
		}
		return fn.apply(self, args);
	};
}
795054
def get_logger(self, logfilename=None):
        
        if self._logger is None:
            self._logger = logging.getLogger('invenio_upgrader')
            self._logger.setLevel(logging.INFO)

            if logfilename:
                fh = logging.FileHandler(logfilename)
                fh.setLevel(logging.INFO)
                fh.setFormatter(self._logger_file_fmtter)
                self._logger.addHandler(fh)

            ch = logging.StreamHandler(sys.stdout)
            ch.setLevel(logging.INFO)
            ch.setFormatter(self._logger_console_fmtter)

            self._logger.addHandler(ch)

            # Replace show warnings (documented in Python manual)
            def showwarning(message, dummy_category, dummy_filename,
                            dummy_lineno, *dummy_args):
                self.warning_occured += 1
                logger = self.get_logger()
                logger.warning(message)
            warnings.showwarning = showwarning

            self._teardown_log_prefix()

        return self._logger
169988
def _create_logger_(name):
    """"""
    logger = logging.getLogger(name)
    handler = logging.StreamHandler()
    handler.setFormatter(logging.Formatter('%(levelname)s %(message)s'))
    logger.addHandler(handler)
    logger.setLevel(logging.INFO)
    return logger
426700
function(logger) {
			if (typeof logger != "object"
				|| typeof logger.info != "function"
				|| typeof logger.debug != "function"
				|| typeof logger.warning != "function"
				|| typeof logger.error != "function"
			) {
				throw new Error("Logger is not valid. It should implement at least the functions: info, debug, warning, error.");
			}
			_private.oLog = logger;
		}
733222
def addLogger(self, logger, level=logging.INFO):
        
        if isinstance(logger, logging.Logger):
            logger = logger.name
        
        if logger in self._loggers:
            return
        
        # allow the handler to determine the level for this logger
        if logger == 'root':
            _log = logging.getLogger()
        else:
            _log = logging.getLogger(logger)
        
        _log.addHandler(self.handler())
        
        self._loggers.add(logger)
        self.handler().setLoggerLevel(logger, level)
1263997
def logger(height=1):                 # http://stackoverflow.com/a/900404/48251
    
    caller = inspect.stack()[height]
    scope = caller[0].f_globals
    function = caller[3]
    path = scope["__name__"]
    if path == "__main__" and scope["__package__"]:
        path = scope["__package__"]
    return logging.getLogger(path + "." + function + "()")
859104
def get_logger(self):
        
        if Global.LOGGER:
            Global.LOGGER.debug('configuring a logger')
        if self._logger_instance is not None:
            return self._logger_instance

        self._logger_instance = logging.getLogger("flowsLogger")
        self._logger_instance.setLevel(logging.DEBUG)

        log_format = '%(asctime)s - [%(levelname)s]|%(thread)d\t%(message)s'
        log_date_format = '%Y-%m-%d %H:%M:%S'
        formatter = logging.Formatter(log_format, log_date_format)

        new_log_stream_handler = logging.StreamHandler()
        new_log_stream_handler.setFormatter(formatter)
        new_log_stream_handler.setLevel(logging.INFO)

        self._logger_instance.addHandler(new_log_stream_handler)

        return self._logger_instance
1042731
def create_serving_logger() -> Logger:
    
    logger = getLogger('quart.serving')

    if logger.level == NOTSET:
        logger.setLevel(INFO)

    logger.addHandler(serving_handler)
    return logger
1105422
def log_trace(logger, level=logging.DEBUG, show_enter=True, show_exit=True):
    
    def wrap(function):
        l = logger.getChild(function.__name__).log
        @wraps(function)
        def thunk(*args, **kwargs):
            global trace_depth
            trace_depth.value += 1
            try:
                start = time()
                if show_enter:
                    l(level, "{0}> {1} {2}".format(" "*trace_depth.value,
                                                   args, kwargs))
                try:
                    result = function(*args, **kwargs)
                except:
                    _, result, _ = sys.exc_info()
                    raise
                finally:
                    if show_exit:
                        l(level, "{0}< return {1} [{2:.2f} sec]".format(
                            " "*trace_depth.value, result, time() - start))
            finally:
                trace_depth.value -= 1
            return result
        return thunk
    return wrap
1047246
def install_logger(logger=None, module=None):
    

    logger = logging.getLogger(Constants.logger) if logger is None else logger
    if module is None:
        # Note: inspect.getmodule() can return the wrong module if it has been imported with different relatives paths.
        module = sys.modules.get(inspect.currentframe().f_back.f_globals["__name__"])
    setattr(module, "LOGGER", logger)

    foundations.trace.register_module(module)

    return logger
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])
807627
def deprecated(message=DEPRECATION_MESSAGE, logger=None):
    
    if logger is None:
        logger = default_logger
    def _deprecated(f):
        def _wrapper(*args, **kwargs):
            f_name = f.__name__
            logger.warning(message.format(name=f_name))
            result = f(*args, **kwargs)
            return result
        return _wrapper
    return _deprecated
757370
def init_log(logger, filename=None, loglevel=None):
    
    
    formatter = logging.Formatter(
                    '[%(asctime)s] %(levelname)s: %(name)s: %(message)s'
                )
    
    if loglevel:
        logger.setLevel(getattr(logging, loglevel))

    # We will allways print warnings and higher to stderr
    ch = logging.StreamHandler()
    ch.setLevel('WARNING')
    ch.setFormatter(formatter)
    
    if filename:
        fi = logging.FileHandler(filename, encoding='utf-8')
        if loglevel:
            fi.setLevel(getattr(logging, loglevel))
        fi.setFormatter(formatter)
        logger.addHandler(fi)
    # If no logfile is provided we print all log messages that the user has 
    # defined to stderr
    else:
        if loglevel:
            ch.setLevel(getattr(logging, loglevel))

    logger.addHandler(ch)
967776
def create_logger(name):
    
    logging.config.dictConfig({
        'version': 1,
        'disable_existing_loggers': False,
        'formatters': {
            'simple': {
                'format': '%(asctime)s [%(levelname)s] %(name)s: %(message)s'
            },
            'detailed': {
                'format': '%(asctime)s %(module)-17s line:%(lineno)-4d '
                          '%(levelname)-8s %(message)s'
            },
            'email': {
                'format': 'Timestamp: %(asctime)s\nModule: %(module)s\n'
                          'Line: %(lineno)d\nMessage: %(message)s'
            },
        },
        'handlers': {
            # 'stream': {
            #     'level': 'DEBUG',
            #     'class': 'logging.StreamHandler',
            #     "formatter": "simple"
            # },
            "file": {
                "level": "DEBUG",
                "formatter": "simple",
                "class": "logging.handlers.RotatingFileHandler",
                "filename": "debug.log",
                'mode': 'a',
                'maxBytes': 30000,
                'backupCount': 0
            }
        },
        'loggers': {
            '': {
                # "handlers": ["stream", "file"],
                "handlers": ["file"],
                "level": "DEBUG",
                'propagate': True
            }
        }
    })
    return logging.getLogger(name)