Get a logger by name

    if file_name is specified, and the dirname() of the file_name exists, it will
    write to that file. If the dirname dies not exist, it will silently ignre it.
18503
def get_logger(
        name, file_name=None, stream=None, template=None, propagate=False):
    

    logger = logging.getLogger(name)

    if propagate is not None:
        logger.propagate = propagate

    for handler in logger.handlers:
        logger.removeHandler(handler)

    if not template:
        template = "%(name)s %(process)s %(levelname)s %(message)s"

    formatter = logging.Formatter(template)

    if not file_name and not stream:
        stream = sys.stdout

    handlers = []

    if stream is not None:

        handlers.append(logging.StreamHandler(stream=stream))

    if file_name is not None:

        if os.path.isdir(os.path.dirname(file_name)):
            handlers.append(logging.FileHandler(file_name))
        else:
            print("ERROR: Can't open log file {}".format(file_name))

    for ch in handlers:
        ch.setFormatter(formatter)
        logger.addHandler(ch)

    logger.setLevel(logging.INFO)

    return logger
594823
public static Logger getLogger(String name) {
        ILoggerFactory iLoggerFactory = getILoggerFactory();
        return iLoggerFactory.getLogger(name);
    }
543812
def create_logger(name: str) -> Logger:
    
    logger = logging.getLogger(f"{PACKAGE_NAME}.{name}")
    logger.addHandler(StreamHandler())
    return logger
874335
def get_logger(cls, custom_name=None):
        """"""
        name = custom_name or cls.get_name()
        return logging.getLogger(name)
1058187
def get_file(self, attr_name):
        ''''''
        return os.path.abspath(os.path.join(self.folder, "{}.log"
                                            .format(attr_name)))
3039
def watched_file_handler(name, logname, filename, mode='a', encoding=None,
                         delay=False):
    

    return wrap_log_handler(logging.handlers.WatchedFileHandler(
        filename, mode=mode, encoding=encoding, delay=delay))
628083
def capture_logger(name):
    
    import logging

    logger = logging.getLogger(name)
    try:
        import StringIO
        stream = StringIO.StringIO()
    except ImportError:
        from io import StringIO
        stream = StringIO()
    handler = logging.StreamHandler(stream)
    logger.addHandler(handler)
    try:
        yield stream
    finally:
        logger.removeHandler(handler)
529211
def __set_log_file_name(self):
        """"""
        # ensure directory exists
        dir, _ = os.path.split(self.__logFileBasename)
        if len(dir) and not os.path.exists(dir):
            os.makedirs(dir)
        # create logFileName
        self.__logFileName = self.__logFileBasename+"."+self.__logFileExtension
        number = 0
        while os.path.isfile(self.__logFileName):
            if os.stat(self.__logFileName).st_size/1e6 < self.__maxlogFileSize:
                break
            number += 1
            self.__logFileName = self.__logFileBasename+"_"+str(number)+"."+self.__logFileExtension
        # create log file stram
        self.__logFileStream = None
667322
def get_logger(name='', log_stream=None, log_file=None,
               quiet=False, verbose=False):
    """"""

    # configure root logger
    log_level = logging.INFO
    if quiet:
        log_level = logging.WARNING
    elif verbose:
        log_level = logging.DEBUG

    if log_stream is None:
        log_stream = sys.stdout

    new_logger = configure_logger(name, log_stream=log_stream,
                                  log_file=log_file, log_level=log_level)

    return new_logger
384082
def get_logger(name):
    
    logger = logging.getLogger(name)
    logger.addHandler(logging.NullHandler())
    return logger
980334
public function checkDir($dir_name)
    {
        $this->file_reference_provider->loadReferenceCache();

        $this->checkDirWithConfig($dir_name, $this->config, true);

        if ($this->output_format === self::TYPE_CONSOLE) {
            echo 'Scanning files...' . "\n";
        }

        $this->config->initializePlugins($this);

        $this->codebase->scanFiles($this->threads);

        $this->config->visitStubFiles($this->codebase, $this->debug_output);

        if ($this->output_format === self::TYPE_CONSOLE) {
            echo 'Analyzing files...' . "\n";
        }

        $this->codebase->analyzer->analyzeFiles($this, $this->threads, $this->codebase->alter_code);
    }
34544
public synchronized static Logging getLogger(final String name) {
    Logging logger = loggers.get(name);
    if(logger == null) {
      logger = new Logging(Logger.getLogger(name));
      loggers.put(name, logger);
    }
    return logger;
  }
1174356
def init_logger(root_dir, name="train.log"):
    
    os.makedirs(root_dir, exist_ok=True)
    log_formatter = logging.Formatter("%(message)s")
    logger = logging.getLogger(name)
    file_handler = logging.FileHandler("{0}/{1}".format(root_dir, name), mode='w')
    file_handler.setFormatter(log_formatter)
    logger.addHandler(file_handler)
    console_handler = logging.StreamHandler()
    console_handler.setFormatter(log_formatter)
    logger.addHandler(console_handler)
    logger.setLevel(logging.INFO)
    return logger
1090099
def start_file_logger(self, name, log_file_level=logging.DEBUG, log_file_path='./'):
        """"""

        log_file_path = os.path.expanduser(log_file_path) / '{}.log'.format(name)
        logdir = log_file_path.parent

        try:
            logdir.mkdir(parents=True, exist_ok=True)

            # If the log file exists, backs it up before creating a new file handler
            if log_file_path.exists():
                strtime = datetime.datetime.utcnow().strftime('%Y-%m-%d_%H:%M:%S')
                shutil.move(log_file_path, log_file_path + '.' + strtime)

            self.fh = TimedRotatingFileHandler(str(log_file_path), when='midnight', utc=True)
            self.fh.suffix = '%Y-%m-%d_%H:%M:%S'
        except (IOError, OSError) as ee:
            warnings.warn('log file {0!r} could not be opened for writing: '
                          '{1}'.format(log_file_path, ee), RuntimeWarning)
        else:
            self.fh.setFormatter(fmt)
            self.addHandler(self.fh)
            self.fh.setLevel(log_file_level)

        self.log_filename = log_file_path
215951
def get_logger(process_name, append_to_console=None, redirect_stdstream=None):
    
    if append_to_console is None:
        append_to_console = settings.settings['under_test']
    if redirect_stdstream is None:
        redirect_stdstream=not settings.settings['under_test']

    if process_name not in logger_pool:
        file_name = get_log_filename(process_name)
        log_tag = get_log_tag(process_name)
        logger_pool[process_name] = Logger(file_name, log_tag,
                                           append_to_console=append_to_console,
                                           redirect_stdstream=redirect_stdstream)
    return logger_pool[process_name].get_logger()
1297768
def getLogger(name):
    '''  '''

    # Create logger and add a default NULL handler
    log = logging.getLogger(name)
    log.addHandler(_NullHandler())

    return log
121392
def get_logger(name, level=0):
        """"""
        level = 0 if not isinstance(level, int) else level
        level = 0 if level < 0 else level
        level = 4 if level > 4 else level
        console = logging.StreamHandler()
        level = [logging.NOTSET, logging.ERROR, logging.WARN, logging.INFO,
                 logging.DEBUG][level]
        console.setLevel(level)
        formatter = logging.Formatter(LOGGING_FORMAT)
        console.setFormatter(formatter)
        logging.getLogger('').addHandler(console)
        return logging.getLogger(name)