Wraps a function that has a connection passed such that everything that
    happens on the connection is logged using the given logger.

    :type  logger: Logger
    :param logger: The logger that handles the logging.
424687
def log_to(logger):
    
    logger_id = id(logger)

    def decorator(function):
        func = add_label(function, 'log_to', logger_id=logger_id)
        return func
    return decorator
612996
def setup_logger(log=None, level=logging.INFO):
    
    if not log:
        log = logging.getLogger()
    if not log.handlers:
        channel = logging.StreamHandler()
        if level == logging.DEBUG:
            channel.setFormatter(DebugLogFormatter())
        else:
            channel.setFormatter(LogFormatter())

        log.setLevel(level)
        log.addHandler(channel)
1315829
def producer(cfg_uri, queue, logger=None):
    
    _info, _exception = _deal_logger(logger)
    cfg_uri = _deal_uri(cfg_uri)

    def decorator(function):
        @wraps(function)
        def wapper(*args, **kwargs):
            client = _conn(cfg_uri, queue, _info)
            for item in function(*args, **kwargs):
                try:
                    if not isinstance(item, dict):
                        item = {'data': item}
                    data = dumps(item, ensure_ascii=False)
                    client.send(queue, data, headers={'persistent': 'true'})
                    _info('Producer insert %s - %s' % (queue, item))
                except ProducerFatalError, e:
                    _exception(e)
                    break
                except Exception, e:
                    _exception(e)
            client.disconnect()
            _info('disconnected %s' % cfg_uri)
        return wapper
    return decorator
1232507
def logger(self):
        
        if self._logger is None:
            self._logger = self.new_logger()
        return self._logger
1342791
public static List<ILoggingEvent> capture(Logger logger) {
        CaptureAppender capture = new CaptureAppender();
        ((ch.qos.logback.classic.Logger) logger).addAppender(capture);
        capture.start();
        return capture.captured;
    }
1041301
public static <T> Parameters.Builder<T> logger(Logger logger) {
        return Parameters.<T> builder().logger(logger);
    }
824235
def logged(level=logging.DEBUG):
    
    def wrap(f):
        _logger = logging.getLogger("{}.{}".format(f.__module__, f.__name__))

        def wrapped_f(*args, **kwargs):
            _logger.log(level, "Called at {} with args = {} and kwargs = {}"
                        .format(datetime.datetime.now(), args, kwargs))
            data = f(*args, **kwargs)
            _logger.log(level, "Done at {} with args = {} and kwargs = {}"
                        .format(datetime.datetime.now(), args, kwargs))
            return data

        return wrapped_f
    return wrap
447043
function LogWrapper (isLogging) {
  if (this.constructor.name === 'Function') {
    throw new Error('Missing object context')
  }

  if (!isLogging) {
    // stub the logger out
    this.logger = {}

    this.logger.info = function () {}
    this.logger.error = function () {}
    this.logger.warn = function () {}
    return
  }

  // Else config winston for logging
  const Winston = require('winston')

  let winstonTransport = new (Winston.transports.Console)({
    json: false,
    colorize: true
  })

  this.logger = new (Winston.Logger)({
    transports: [winstonTransport]
  })
}
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)
300237
function Logger(logger, options) {
    options = options || {};

    /**
     * ### Logger.logger
     *
     * The Winston logger
     *
     * @see Winston
     */
    this.logger = winston.loggers.get(logger);

    /**
     * ### Logger.name
     *
     * The name of the logger (might be the name of the channel).
     *
     * @see ServerChannel
     */
    this.name = options.name;

    // Set the appropriate log function.
    if (logger === 'messages') this.log = this.logMsg;
    else this.log = this.logText;
}
641051
def create_logger(name, formatter=None, handler=None, level=None):
    
    logger = logging.getLogger(name)

    #: remove existing handlers
    logger.handlers = []

    #: use a standard out handler
    if handler is None:
        handler = logging.StreamHandler(sys.stdout)

    #: set the formatter when a formatter is given
    if formatter is not None:
        handler.setFormatter(formatter)

    #: set DEBUG level if no level is specified
    if level is None:
        level = logging.DEBUG

    handler.setLevel(level)
    logger.setLevel(level)
    logger.addHandler(handler)
    return logger
1120373
def get_logger(name=None):
    '''
    
    '''
    logger = logging.getLogger(name)
    if len(logger.handlers) == 0:
        logger = add_stream_handler(logger)
    return logger
1355987
def debug (logname, msg, *args, **kwargs):
    
    log = logging.getLogger(logname)
    if log.isEnabledFor(logging.DEBUG):
        _log(log.debug, msg, args, **kwargs)
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
243432
def __handler(self, connection, event):
        
        try:
            # Find local handler
            method = getattr(self, "on_{0}".format(event.type))
        except AttributeError:
            pass
        else:
            try:
                # Call it
                return method(connection, event)
            except Exception as ex:
                logging.exception("Error calling handler: %s", ex)
685986
def setup_logger
      @logger = flexmock("logger")
      @logger.should_receive(:level).and_return(:info).by_default
      @logger.should_receive(:error).by_default.and_return { |m| raise m }
      @logger.should_receive(:warn).by_default.and_return { |m| raise m }
      @logger.should_receive(:info).by_default
      @logger.should_receive(:debug).by_default
      # Note that the following puts the mock logger inside the default Decorator
      # so the only way to mock the :exception interface is to flexmock the
      # logger if the constructed class that uses RightSupport::Log::Mixin
      RightSupport::Log::Mixin.default_logger = @logger
    end
199867
def getLogger(*args, **kwargs):
    
    logger = logging.getLogger(*args, **kwargs)
    if _overrideLogLevel is not None:
        logger.setLevel(logging.NOTSET)
    return logger