Instantiate logger

    Parameters
    ----------
    log_dir: str
        Directory to save log, default: ~/.ding0/logging/
    loglevel: 
        Level of logger.
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
399973
def init_logging(log_level):
    
    log_level = log_level_to_string_map[min(log_level, 5)]

    msg = "%(levelname)s - %(name)s:%(lineno)s - %(message)s" if log_level in os.environ else "%(levelname)s - %(message)s"

    logging_conf = {
        "version": 1,
        "root": {
            "level": log_level,
            "handlers": ["console"]
        },
        "handlers": {
            "console": {
                "class": "logging.StreamHandler",
                "level": log_level,
                "formatter": "simple",
                "stream": "ext://sys.stdout"
            }
        },
        "formatters": {
            "simple": {
                "format": " {0}".format(msg)
            }
        }
    }

    logging.config.dictConfig(logging_conf)
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)
166091
def _setup_logging(self):
        
        self._log_level_delta = (self._args.quiet * 10) - (self._args.verbose * 10)
        level = max(1, self._default_log_level + self._log_level_delta)
        logging.basicConfig(level=level, format=LOG_FORMAT)
1188772
def log(self, level, message):
        '''

        '''
        if self.log_fd is not None:
            prefix = struct.pack('ii', level, len(message))
            os.write(self.log_fd, prefix)
            os.write(self.log_fd, message)
787372
def writeLogToFile(self):
        
        if not os.path.exists(self.logFolder):
            os.mkdir(self.logFolder)

        with open(self.logFile, mode='a') as f:
            f.write('\n\n' + self.log)
303061
def log_to_file(logdir, mode='a', delete=False, clearmem=True):
    
    logger = FileLogger(logdir, mode, delete, clearmem)
    _loggers.append(logger)
    return log_to(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
579809
def log_init(level):
    
    log = logging.getLogger()
    hdlr = logging.StreamHandler()
    formatter = logging.Formatter('%(asctime)s %(name)s %(levelname)s %(message)s')
    hdlr.setFormatter(formatter)
    log.addHandler(hdlr)
    log.setLevel(level)
1005319
def log_level(io_handler, level=None, name=None):
        
        # Get the logger
        logger = logging.getLogger(name)

        # Normalize the name
        if not name:
            name = "Root"

        if not level:
            # Level not given: print the logger level
            io_handler.write_line(
                "{0} log level: {1} (real: {2})",
                name,
                logging.getLevelName(logger.getEffectiveLevel()),
                logging.getLevelName(logger.level),
            )
        else:
            # Set the logger level
            try:
                logger.setLevel(level.upper())
                io_handler.write_line("New level for {0}: {1}", name, level)
            except ValueError:
                io_handler.write_line("Invalid log level: {0}", level)
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
1095351
def log(self, message, level='info'):
        
        getattr(self.logger, level)('[%s] %s' % (self.id, message))
887417
def setup_logging(level):
    
    format = "[%(asctime)s] %(levelname)s:%(name)s:%(message)s"
    logging.basicConfig(
        level=level, stream=sys.stdout, format=format, datefmt="%Y-%m-%d %H:%M:%S"
    )
742091
def set_log_level(self, level):
        
        self._log_level = level
        if self._python_logger:
            try:
                level = self.PYTHON_LEVEL.get(level)
            except ValueError as err:
                raise FailReply("Unknown logging level '%s'" % (level))
            self._python_logger.setLevel(level)
816613
def init_logger():
    
    formatter = logging.Formatter('%(levelname)s: %(message)s')
    console = logging.StreamHandler(stream=sys.stdout)
    console.setLevel(logging.INFO)
    console.setFormatter(formatter)
    logger.addHandler(console)
190946
public static void log(Logger logger,
                           Level level,
                           String message) {
        log(logger, level, message, NO_PARAMETERS);
    }
1297723
def _create_logger(name='fmf', 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 cache and xmlrpc
        logger.DATA = LOG_DATA
        logger.CACHE = LOG_CACHE
        logger.ALL = LOG_ALL
        logger.cache = lambda message: logger.log(LOG_CACHE, message) # NOQA
        logger.data = lambda message: logger.log(LOG_DATA, message) # NOQA
        logger.all = lambda message: logger.log(LOG_ALL, message) # NOQA
        return logger