Initialize logging
323806
def Logs(loggername, echo=True, debug=False, chatty=False, loglevel=logging.INFO, logfile=None, logpath=None, fileHandler=None):
    
    log = logging.getLogger(loggername)

    if fileHandler is None:
        if logfile is None:
            logFilename = _ourName
        else:
            logFilename = logfile

        if '.log' not in logFilename:
            logFilename = '%s.log' % logFilename

        if logpath is not None:
            logFilename = os.path.join(logpath, logFilename)

        _handler   = logging.FileHandler(logFilename)
        _formatter = logging.Formatter('%(asctime)s %(levelname)-7s %(message)s')

        _handler.setFormatter(_formatter)
        log.addHandler(_handler)
        # logging.fileHandler = _handler
    else:
        log.addHandler(fileHandler)
        # logging.fileHandler = fileHandler

    if echo:
        echoHandler = logging.StreamHandler()
        if chatty:
            echoFormatter = logging.Formatter('%(asctime)s %(levelname)-7s %(processName)s[%(process)d]: %(message)s')
        else:
            echoFormatter = logging.Formatter('%(asctime)s %(levelname)-7s %(message)s')
        echoHandler.setFormatter(echoFormatter)
        log.addHandler(echoHandler)

    if debug:
        log.setLevel(logging.DEBUG)
    else:
        log.setLevel(loglevel)

    atexit.register(shutdownLogging)
894209
def setup_logging():
    
    fmt = 'DBG<0>%(pathname)s:%(lineno)d  %(funcName)s: %(message)s'

    handler_stderr = logging.StreamHandler(sys.stderr)
    handler_stderr.setFormatter(logging.Formatter(fmt))
    if OPTIONS['--verbose'] == 1:
        handler_stderr.addFilter(logging.Filter(__name__))

    root_logger = logging.getLogger()
    root_logger.setLevel(logging.DEBUG)
    root_logger.addHandler(handler_stderr)
326344
def _initialize_logging():
    

    # Starting the console handler if a terminal is available.
    if sys.stdout.isatty() or platform.system() in ("Darwin", "Linux"):
        RuntimeGlobals.logging_console_handler = foundations.verbose.get_logging_console_handler()

    # Defining logging formatters.
    RuntimeGlobals.logging_formatters = {"Default": foundations.verbose.LOGGING_DEFAULT_FORMATTER,
                                         "Extended": foundations.verbose.LOGGING_EXTENDED_FORMATTER,
                                         "Standard": foundations.verbose.LOGGING_STANDARD_FORMATTER}
302328
def _init_logging(verbose):
    """"""
    hdlr = logging.StreamHandler()
    hdlr.setFormatter(logging.Formatter(
        '%(asctime)s [%(levelname)s] [%(module)s] %(message)s'))
    LOG.addHandler(hdlr)
    if verbose:
        LOG.setLevel(logging.DEBUG)
        LOG.debug('Verbose output enabled.')
    else:
        LOG.setLevel(logging.INFO)
1140494
def init_logs(args, tool="NanoPlot"):
    """"""
    start_time = dt.fromtimestamp(time()).strftime('%Y%m%d_%H%M')
    logname = os.path.join(args.outdir, args.prefix + tool + "_" + start_time + ".log")
    handlers = [logging.FileHandler(logname)]
    if args.verbose:
        handlers.append(logging.StreamHandler())
    logging.basicConfig(
        format='%(asctime)s %(message)s',
        handlers=handlers,
        level=logging.INFO)
    logging.info('{} {} started with arguments {}'.format(tool, __version__, args))
    logging.info('Python version is: {}'.format(sys.version.replace('\n', ' ')))
    return logname
604175
def init_logging():
    """"""
    fmt = '%(asctime)s.%(msecs)03d | %(name)-60s | %(levelname)-7s ' \
          '| %(message)s'
    logging.basicConfig(format=fmt, datefmt='%H:%M:%S', level=logging.DEBUG)
913655
def init(*, threshold_lvl=1, quiet_stdout=False, log_file):
    
    global _logger, _log_lvl

    # translate lvl to those used by 'logging' module
    _log_lvl = _set_lvl(threshold_lvl)

    # logger Creation
    _logger = logging.getLogger(PKG_NAME)
    _logger.setLevel(_log_lvl)

    # create syslog handler and set level to info
    log_h = logging.FileHandler(log_file)

    # Base message format
    base_fmt = '%(asctime)s - %(name)s - [%(levelname)s] - %(message)s'

    # set formatter
    log_fmt = logging.Formatter(base_fmt)
    log_h.setFormatter(log_fmt)
    # add Handler
    _logger.addHandler(log_h)

    # create stout handler
    if not quiet_stdout:
        global _stdout
        _stdout = True
1304982
def setup_logging():
    
    fmt = 'DBG<0>%(pathname)s:%(lineno)d  %(funcName)s: %(message)s'

    handler_stderr = logging.StreamHandler(sys.stderr)
    handler_stderr.setFormatter(logging.Formatter(fmt))

    root_logger = logging.getLogger()
    root_logger.setLevel(logging.DEBUG)
    root_logger.addHandler(handler_stderr)
793418
private static void initLogFile() {
    try (BufferedWriter bw = new BufferedWriter(new FileWriter(getLogPath()))) {
      Date date = new Date();
      bw.write("LT office integration log from " + date.toString() + logLineBreak);
    } catch (Throwable t) {
      showError(t);
    }
  }
1306303
def init_logger(cls, log_level):
        """"""
        logger = logging.getLogger("AutoMLBoard")
        handler = logging.StreamHandler()
        formatter = logging.Formatter("[%(levelname)s %(asctime)s] "
                                      "%(filename)s: %(lineno)d  "
                                      "%(message)s")
        handler.setFormatter(formatter)
        logger.setLevel(log_level)
        logger.addHandler(handler)
        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)
500232
def _init_logs_table():
    """"""
    _logs_table = sqlalchemy.Table(
        'logs', _METADATA,
        sqlalchemy.Column(
            'job_id', sqlalchemy.ForeignKey("jobs.job_id", ondelete="CASCADE"),
            nullable=False),
        sqlalchemy.Column('timestamp', sqlalchemy.DateTime),
        sqlalchemy.Column('message', sqlalchemy.UnicodeText),
        sqlalchemy.Column('level', sqlalchemy.UnicodeText),
        sqlalchemy.Column('module', sqlalchemy.UnicodeText),
        sqlalchemy.Column('funcName', sqlalchemy.UnicodeText),
        sqlalchemy.Column('lineno', sqlalchemy.Integer)
        )
    return _logs_table
780861
def _initialize():
  """"""
  global _absl_logger, _absl_handler

  if _absl_logger:
    return

  original_logger_class = logging.getLoggerClass()
  logging.setLoggerClass(ABSLLogger)
  _absl_logger = logging.getLogger('absl')
  logging.setLoggerClass(original_logger_class)

  python_logging_formatter = PythonFormatter()
  _absl_handler = ABSLHandler(python_logging_formatter)

  # The absl handler logs to stderr by default. To prevent double logging to
  # stderr, the following code tries its best to remove other handlers that emit
  # to stderr. Those handlers are most commonly added when logging.info/debug is
  # called before importing this module.
  handlers = [
      h for h in logging.root.handlers
      if isinstance(h, logging.StreamHandler) and h.stream == sys.stderr]
  for h in handlers:
    logging.root.removeHandler(h)

  # The absl handler will always be attached to root, not the absl logger.
  if not logging.root.handlers:
    # Attach the absl handler at import time when there are no other handlers.
    # Otherwise it means users have explicitly configured logging, and the absl
    # handler will only be attached later in app.run(). For App Engine apps,
    # the absl handler is not used.
    logging.root.addHandler(_absl_handler)
964684
public static function initSysLog() {
			// for CLI logging name is <fqdn-hostname>:<TYPO3-path>
			// Note that TYPO3_REQUESTTYPE is not used here as it may not yet be defined
		if (defined('TYPO3_cliMode') && TYPO3_cliMode) {
			$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'] = self::getHostname($requestHost = FALSE) . ':' . PATH_site;
		}
			// for Web logging name is <protocol>://<request-hostame>/<site-path>
		else {
			$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'] = self::getIndpEnv('TYPO3_SITE_URL');
		}

			// init custom logging
		if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog'])) {
			$params = array('initLog' => TRUE);
			$fakeThis = FALSE;
			foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog'] as $hookMethod) {
				self::callUserFunction($hookMethod, $params, $fakeThis);
			}
		}

			// init TYPO3 logging
		foreach (explode(';', $GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLog'], 2) as $log) {
			list($type, $destination) = explode(',', $log, 3);

			if ($type == 'syslog') {
				if (TYPO3_OS == 'WIN') {
					$facility = LOG_USER;
				} else {
					$facility = constant('LOG_' . strtoupper($destination));
				}
				openlog($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'], LOG_ODELAY, $facility);
			}
		}

		$GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLogLevel'] = t3lib_utility_Math::forceIntegerInRange($GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLogLevel'], 0, 4);
		$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogInit'] = TRUE;
	}
325361
def setup_logging(
    config='logging.yaml',
    default_level=logging.INFO,
    env_key='LOG_CFG'
):
    
    path = config
    value = os.getenv(env_key, None)
    if value:
        path = value

    if path.exists():
        with open(path, 'rt') as f:
            config = yaml.safe_load(f.read())
        logging.config.dictConfig(config)
    else:
        print('cannot read: ' + str(path))
        logging.basicConfig(level=default_level)
627684
def log_init():
    
    fallback_log_level = 'INFO'
    ot_log_level = hardware.config.log_level
    if ot_log_level not in logging._nameToLevel:
        log.info("OT Log Level {} not found. Defaulting to {}".format(
            ot_log_level, fallback_log_level))
        ot_log_level = fallback_log_level

    level_value = logging._nameToLevel[ot_log_level]

    serial_log_filename = CONFIG['serial_log_file']
    api_log_filename = CONFIG['api_log_file']

    logging_config = dict(
        version=1,
        formatters={
            'basic': {
                'format':
                '%(asctime)s %(name)s %(levelname)s [Line %(lineno)s] %(message)s'  # noqa: E501
            }
        },
        handlers={
            'debug': {
                'class': 'logging.StreamHandler',
                'formatter': 'basic',
                'level': level_value
            },
            'serial': {
                'class': 'logging.handlers.RotatingFileHandler',
                'formatter': 'basic',
                'filename': serial_log_filename,
                'maxBytes': 5000000,
                'level': logging.DEBUG,
                'backupCount': 3
            },
            'api': {
                'class': 'logging.handlers.RotatingFileHandler',
                'formatter': 'basic',
                'filename': api_log_filename,
                'maxBytes': 1000000,
                'level': logging.DEBUG,
                'backupCount': 5
            }

        },
        loggers={
            '__main__': {
                'handlers': ['debug', 'api'],
                'level': logging.INFO
            },
            'opentrons.server': {
                'handlers': ['debug', 'api'],
                'level': level_value
            },
            'opentrons.api': {
                'handlers': ['debug', 'api'],
                'level': level_value
            },
            'opentrons.instruments': {
                'handlers': ['debug', 'api'],
                'level': level_value
            },
            'opentrons.config': {
                'handlers': ['debug', 'api'],
                'level': level_value
            },
            'opentrons.drivers.smoothie_drivers.driver_3_0': {
                'handlers': ['debug', 'api'],
                'level': level_value
            },
            'opentrons.drivers.serial_communication': {
                'handlers': ['serial'],
                'level': logging.DEBUG
            },
            'opentrons.drivers.thermocycler.driver': {
                'handlers': ['serial'],
                'level': logging.DEBUG
            },
            'opentrons.protocol_api': {
                'handlers': ['api', 'debug'],
                'level': level_value
            },
            'opentrons.hardware_control': {
                'handlers': ['api', 'debug'],
                'level': level_value
            },
            'opentrons.legacy_api.containers': {
                'handlers': ['api'],
                'level': level_value
            }
        }
    )
    dictConfig(logging_config)
499303
def initialize_log(log)
      close if @log # be sure that we don't leave open files laying around.

      if log.respond_to?(:write)
        @log = log
      elsif File.exist?(log)
        @log = open(log, (File::WRONLY | File::APPEND))
        @log.sync = true
      else
        FileUtils.mkdir_p(File.dirname(log)) unless File.directory?(File.dirname(log))
        @log = open(log, (File::WRONLY | File::APPEND | File::CREAT))
        @log.sync = true
        @log.write("#{Time.now.httpdate} #{delimiter} info #{delimiter} Logfile created\n")
      end
    end