Define target for common output.

    Args:
        logger (bool | None | logging.Logger):
            Pass None to use `print()` to stdout instead of logging.
            Pass True to create a simple standard logger.
348600
def set_pyftpsync_logger(logger=True):
    
    global _logger
    prev_logger = _logger
    if logger is True:
        logging.basicConfig(level=logging.INFO)
        _logger = logging.getLogger("pyftpsync")
        _logger.setLevel(logging.DEBUG)
    else:
        _logger = logger
    return prev_logger
203476
def start_logging(out=_stdout, level='info'):
    
    global _loggers, _observer, _log_level, _started_logging

    if level not in log_levels:
        raise RuntimeError(
            "Invalid log level '{0}'; valid are: {1}".format(
                level, ', '.join(log_levels)
            )
        )

    if _started_logging:
        return

    _started_logging = True

    _log_level = level
    set_global_log_level(_log_level)

    if out:
        _observer = _LogObserver(out)

    if _NEW_LOGGER:
        _observers = []
        if _observer:
            _observers.append(_observer)
        globalLogBeginner.beginLoggingTo(_observers)
    else:
        assert out, "out needs to be given a value if using Twisteds before 15.2"
        from twisted.python import log
        log.startLogging(out)
384286
def disable_logger(self, disabled=True):
        
        # Disable standard IO streams
        if disabled:
            sys.stdout = _original_stdout
            sys.stderr = _original_stderr
        else:
            sys.stdout = self.__stdout_stream
            sys.stderr = self.__stderr_stream

        # Disable handlers
        self.logger.disabled = disabled
682678
def register_logger(self, logger):
        
        handler = CommandHandler(self)
        handler.setFormatter(CommandFormatter())
        logger.handlers = [handler]
        logger.propagate = False

        output = self.output
        level = logging.WARNING
        if output.is_debug():
            level = logging.DEBUG
        elif output.is_very_verbose() or output.is_verbose():
            level = logging.INFO

        logger.setLevel(level)
1120471
def create_handler(target: str):
    """"""
    if target == 'stderr':
        return logging.StreamHandler(sys.stderr)
    elif target == 'stdout':
        return logging.StreamHandler(sys.stdout)
    else:
        return logging.handlers.WatchedFileHandler(filename=target)
787402
def logger
      if !@log_file.respond_to?(:write)
        STDOUT.reopen(File.open(@log_file, (File::WRONLY | File::APPEND | File::CREAT)))
      end
      @logger = Logger.new(STDOUT)
    end
1311582
def logger(*args, **kwargs):
    
    if mpi.within_mpirun and mpi.myrank == 0:
        # tell the workers to invoke the same logger
        mpi.comm.bcast({'worker_command': 'logger', 'args': args, 'kwargs': kwargs}, root=0)

    return _utils.get_basic_logger(*args, **kwargs)
211734
public void setLogger(String logger)
    {
        if(logger != null && logger.trim().length() > 0)
            this.logger = LoggerFactory.getLogger(logger);
    }
468265
def _logger():
        """"""
        logger = logging.getLogger(__name__)
        logger.setLevel(logging.DEBUG)
        ch = logging.StreamHandler(sys.stdout)
        ch.setLevel(logging.DEBUG)
        logger.addHandler(ch)
        return logger
461928
def _set_logger(logger_name, level=logging.INFO):
        
        log = logging.getLogger(logger_name)
        log.setLevel(level)

        ch = logging.StreamHandler(None)
        ch.setLevel(level)

        formatter = logging.Formatter(DebugFmtString)

        # add formatter to ch
        ch.setFormatter(formatter)

        # add ch to logger
        log.addHandler(ch)
788244
def _setup_logger(self, logging_level: int, log_to_console: bool):
        
        self.logger = logging.getLogger('discord')
        self.logger.handlers = []
        self.logger.setLevel(logging_level)
        formatter = logging.Formatter(style='{', fmt='{asctime} [{levelname}] {message}', datefmt='%Y-%m-%d %H:%M:%S')
        file_handler = logging.FileHandler('pycord.log')
        file_handler.setFormatter(formatter)
        file_handler.setLevel(logging_level)
        self.logger.addHandler(file_handler)
        if log_to_console:
            stream_handler = logging.StreamHandler(sys.stdout)
            stream_handler.setFormatter(formatter)
            stream_handler.setLevel(logging_level)
            self.logger.addHandler(stream_handler)
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)
109997
def set_logger(self):
        
        self.logger = logging.getLogger(self.logger_name)
        self.logger.setLevel(self.logger_level)
884706
def output_redirect(stdout, stderr):
  
  import sys
  import threading
  if not redirect:
    originals = (sys.stdout.write, sys.stderr.write)

    class Logger:
      def __init__(self, fun):
        self.buffer = ""
        self.fun = fun

      def logs(self):
        logs = redirect.get(threading.current_thread(), originals)[self.fun]
        # sys.__stdout__.write('hello ' + str(threading.current_thread()))
        if not isinstance(logs, (list, tuple)):
          logs = [logs]
        return logs

      def write(self, s):
        self.buffer += s
        lines = self.buffer.splitlines(keepends=True)
        last = lines[-1]
        if lines[-1][-1] != '\n':
          self.buffer = lines[-1]
          lines = lines[:-1]
        else:
          self.buffer = ""

        for line in lines:
          for log in self.logs():
            getattr(log, 'write', lambda x: log(x))(line)

      def flush_buffer(self):
        if self.buffer:
          for log in self.logs():
            getattr(log, 'write', lambda x: log(x))(self.buffer)

      def close(self):
        for log in self.logs():
          # self.flush_buffer()
          getattr(log, 'close', lambda: None)()

    lsout = Logger(0)
    sys.stdout.write = lsout.write
    sys.stdout.close = lsout.close
    lserr = Logger(1)
    sys.stderr.write = lserr.write
    sys.stderr.close = lserr.close

  # print('red ', threading.current_thread())
  thread = threading.current_thread()
  redirect.update({thread: (stdout, stderr)})
  try:
    yield
  except Exception as e:
    r = redirect.pop(thread, None)
    getattr(r, 'flush_buffer', lambda: None)()
    raise Exception(e) from e
  else:
    r = redirect.pop(thread, None)
    getattr(r, 'flush_buffer', lambda: None)()
1128251
public void setLogger(Logger logger) {
		this.logger = logger == null ? LoggerFactory.getLogger(getClass()) : logger;
	}
427585
def logger():
    """"""
    global _LOGGER
    if _LOGGER is None:
        logging.basicConfig()
        _LOGGER = logging.getLogger()
        _LOGGER.setLevel('INFO')
    return _LOGGER
659795
def set_logger(self, logger_name, level=logging.INFO):
        
        log = logging.getLogger(logger_name)
        log.setLevel(level)

        ch = logging.StreamHandler(None)
        ch.setLevel(level)

        # create formatter
        if level == logging.INFO:
            formatter = logging.Formatter(InfoFmtString)
        else:
            formatter = logging.Formatter(DebugFmtString)

        # add formatter to ch
        ch.setFormatter(formatter)

        # add ch to logger
        log.addHandler(ch)