Override `log()` if bot is not initialized with a database
        connection. Do not call this method directly.
171819
def _log_to_file(self, etype, source, msg='', target='', hostmask='', params=''):
        
        today = datetime.utcnow()
        # TODO: Use self.locale['timezone'] for changing time
        date = today.strftime(self.locale['date_fmt'])
        time = today.strftime(self.locale['time_fmt'])
        datetime_s = today.strftime(self.locale['short_datetime_fmt'])
        datetime_l = today.strftime(self.locale['long_datetime_fmt'])
        
        if target == self.nickname and etype in ('privmsg', 'action'):
            target = source

        if etype in self.log_formats:
            file_path = os.path.expanduser(self.log_file.format(**locals()))
            file_dir = os.path.dirname(file_path)
            if not os.path.isdir(file_dir):
                os.makedirs(file_dir)

            line = self.log_formats[etype].format(**locals())
            with open(file_path, 'a') as log:
                log.write(line+'\n')
688587
def _log(pid, request, event, timestamp=None):
    """"""
    # Support logging events that are not associated with an object.
    sciobj_model = None
    if pid is not None:
        try:
            sciobj_model = d1_gmn.app.models.ScienceObject.objects.filter(pid__did=pid)[
                0
            ]
        except IndexError:
            raise d1_common.types.exceptions.ServiceFailure(
                0,
                'Attempted to create event log for non-existing object. pid="{}"'.format(
                    pid
                ),
            )

    event_log_model = create_log_entry(
        sciobj_model,
        event,
        request.META['REMOTE_ADDR'],
        request.META.get('HTTP_USER_AGENT', '<not provided>'),
        request.primary_subject_str,
    )

    # The datetime is an optional parameter. If it is not provided, a
    # "auto_now_add=True" value in the the model defaults it to Now. The
    # disadvantage to this approach is that we have to update the timestamp in a
    # separate step if we want to set it to anything other than Now.
    if timestamp is not None:
        event_log_model.timestamp = timestamp
        event_log_model.save()
440192
private void doWait(long loginTimeoutExpiration) throws SQLException {

        try {
            if (loginTimeoutExpiration > 0) {
                long timeToWait = loginTimeoutExpiration
                                  - System.currentTimeMillis();

                if (timeToWait > 0) {
                    this.wait(timeToWait);
                } else {
                    throw new SQLException(
                        "No connections available within the given login timeout: "
                        + getLoginTimeout());
                }
            } else {
                this.wait();
            }
        } catch (InterruptedException e) {
            throw new SQLException(
                "Thread was interrupted while waiting for available connection");
        }
    }
1195672
@SuppressWarnings( { "NestedTryStatement" })
    public void init_logger() {
	try {
	    Util.out4.println("Initializing logging for " + get_name());
	    // - Get Util instance
	    final Util util = Util.instance();
	    // - Get cmd line logging level then ...
	    final int trace_level = util.get_trace_level();
	    // ... convert it to log4j level
	    Level cmd_line_level;
	    // does the logging level set from cmd line?
	    boolean level_set_from_cmd_line = true;
	    if (trace_level <= 0) {
		level_set_from_cmd_line = false;
		cmd_line_level = Level.OFF;
	    } else if (trace_level <= 2) {
		cmd_line_level = Level.INFO;
	    } else {
		cmd_line_level = Level.DEBUG;
	    }
	    // - Add a console target if logging level set from cmd line
	    if (level_set_from_cmd_line) {
		// add a console target if logging level set from cmd line
		try {
		    Logging.instance().add_logging_target(get_logger(), LOGGING_CONSOLE_TARGET);
		} catch (final DevFailed df) {
		    /** ignore exception */
		}
	    }
	    if (!Util._UseDb) {
		// - Done if we are not using the database
		Util.out4.println("Not using the database. Logging Intialization complete");
		return;
	    }
	    // - Get both logging level and targets from database
	    final Logging.LoggingProperties properties = Logging.instance().get_logging_properties(
		    get_logger(), util.get_database());
	    if (properties == null) {
		Util.out4.println("Failed to obtain logging properties from database");
		Util.out4.println("Aborting logging intialization");
		get_logger().setLevel(cmd_line_level);
		return;
	    }
	    // - Set logging level
	    if (level_set_from_cmd_line == false) {
		get_logger().setLevel(properties.logging_level);
		Util.out4.println("Logging level set to " + properties.logging_level.toString());
	    } else {
		get_logger().setLevel(cmd_line_level);
	    }
	    // - Save current logging level
	    last_level = get_logger().getLevel();
	    // - Get rolling threshold for file targets
	    if (rft != properties.logging_rft) {
		rft = properties.logging_rft;
		Util.out4.println("Rolling threshold changed to " + String.valueOf(rft));
	    }
	    // - Set logging targets
	    if (properties.logging_targets != null) {
		Util.out4.println("Adding logging targets (" + properties.logging_targets.length
			+ " entries in db)");
		for (final String logging_target : properties.logging_targets) {
		    try {
			Logging.instance().add_logging_target(get_logger(), logging_target);
		    } catch (final DevFailed e) { /* ignore any exception */
		    }
		}
	    }
	    // set rolling file threshold for file targets
	    Logging.instance().set_rolling_file_threshold(get_logger(), rft);
	} catch (final Exception e) {
	    // igore any exception
	}
    }
93716
function log(conn, name, message) {
    if (! show_sql) {
        return;
    }
    function padding(n, len) {
        var
            s = n.toString(),
            p = len - s.length;
        while (p > 0) {
            s = '0' + s;
            p--;
        }
        return s;
    }
    var
        d = new Date(),
        h = d.getHours(),
        m = d.getMinutes(),
        s = d.getSeconds(),
        ms = d.getMilliseconds(),
        date = padding(h, 2) + ':' + padding(m, 2) + ':' + padding(s, 2) + '.' + padding(ms, 3);
    console.log(date + (conn ? (' [Warp@' + conn.__objectId + '] ') : ' ') + name + ': ' + message);
}
591922
def log(self, level, msg=None, *args, **kwargs):
        """"""

        return self._log(level, msg, args, kwargs)
174013
def initialize(config):
	""
	config = init_config(config)

	_setup_logging()
	_load_library_extensions()
	if not Handler._registry:
		raise RuntimeError("No handlers registered")

	class_ = _load_bot_class()

	config.setdefault('log_channels', [])
	config.setdefault('other_channels', [])

	channels = config.log_channels + config.other_channels

	log.info('Running with config')
	log.info(pprint.pformat(config))

	host = config.get('server_host', 'localhost')
	port = config.get('server_port', 6667)

	return class_(
		host,
		port,
		config.bot_nickname,
		channels=channels,
		password=config.get('password'),
	)
871123
def default_logging(grab_log=None, # '/tmp/grab.log',
                    network_log=None, # '/tmp/grab.network.log',
                    level=logging.DEBUG, mode='a',
                    propagate_network_logger=False):
    

    logging.basicConfig(level=level)

    network_logger = logging.getLogger('grab.network')
    network_logger.propagate = propagate_network_logger
    if network_log:
        hdl = logging.FileHandler(network_log, mode)
        network_logger.addHandler(hdl)
        network_logger.setLevel(level)

    grab_logger = logging.getLogger('grab')
    if grab_log:
        hdl = logging.FileHandler(grab_log, mode)
        grab_logger.addHandler(hdl)
        grab_logger.setLevel(level)
199867
def getLogger(*args, **kwargs):
    
    logger = logging.getLogger(*args, **kwargs)
    if _overrideLogLevel is not None:
        logger.setLevel(logging.NOTSET)
    return logger
222041
def init_logger(self):
        """"""
        # All logs are comming to this logger
        self.logger.setLevel(logging.DEBUG)
        self.logger.propagate = False

        # Logging to console
        if self.min_log_level_to_print:
            level = self.min_log_level_to_print
            handler_class = logging.StreamHandler
            self._create_handler(handler_class, level)

        # Logging to file
        if self.min_log_level_to_save:
            level = self.min_log_level_to_save
            handler_class = logging.handlers.TimedRotatingFileHandler
            self._create_handler(handler_class, level)

        # Logging to syslog
        if self.min_log_level_to_syslog:
            level = self.min_log_level_to_syslog
            handler_class = logging.handlers.SysLogHandler
            self._create_handler(handler_class, level)

        # Logging to email
        if self.min_log_level_to_mail:
            level = self.min_log_level_to_mail
            handler_class = AlkiviEmailHandler
            self._create_handler(handler_class, level)

        return
583622
def initialize_logging(self):
        """"""
        # Reset logging to pass logrecords into the queue to the frontend only.
        # Existing handlers may be broken as they were copied into a new process,
        # so should be discarded.
        for loggername in [None] + list(logging.Logger.manager.loggerDict.keys()):
            logger = logging.getLogger(loggername)
            while logger.handlers:
                logger.removeHandler(logger.handlers[0])

        # Re-enable logging to console
        root_logger = logging.getLogger()

        # By default pass all warning (and higher) level messages to the frontend
        root_logger.setLevel(logging.WARN)
        root_logger.addHandler(workflows.logging.CallbackHandler(self._log_send))

        # Set up the service logger and pass all info (and higher) level messages
        # (or other level if set differently)
        self.log = logging.getLogger(self._logger_name)

        if self.start_kwargs.get("verbose_log"):
            self.log_verbosity = logging.DEBUG
        self.log.setLevel(self.log_verbosity)

        # Additionally, write all critical messages directly to console
        console = logging.StreamHandler()
        console.setLevel(logging.CRITICAL)
        root_logger.addHandler(console)
922529
def log(self, *args, **kwargs):
        
        if self.suppress_errors:
            try:
                self._log(*args, **kwargs)
                return True
            except:
                return False
        else:
            self._log(*args, **kwargs)
            return True
347823
def initLogging(self):
        """"""
        verbose_levels = {
            0: logging.WARNING,
            1: logging.INFO,
            2: logging.DEBUG,
        }
        logging.basicConfig(
            level=verbose_levels[self.verbose],
            format="[%(asctime)-15s] %(module)-9s %(levelname)-7s %(message)s"
        )
        return logging.getLogger(self.__class__.__name__)
998212
def init_log(log_level):
    """"""
    log_level = log_level or "INFO"
    logging.basicConfig(
        format="%(name)s:%(levelname)s:%(message)s",
        level=getattr(logging, log_level.upper(), logging.INFO),
    )
565101
function log() {
  if (typeof print === 'function') {
    print.apply(this, arguments)
  } else {
    console.log.apply(console, arguments)
  }
}
493676
def logger_init():
    """"""
    log = logging.getLogger("pyinotify")
    console_handler = logging.StreamHandler()
    console_handler.setFormatter(
        logging.Formatter("[%(asctime)s %(name)s %(levelname)s] %(message)s"))
    log.addHandler(console_handler)
    log.setLevel(20)
    return log
1018191
def log_method(log, level=logging.DEBUG):
    """"""

    def decorator(func):
        func_name = func.__name__

        @six.wraps(func)
        def wrapper(self, *args, **kwargs):
            if log.isEnabledFor(level):
                pretty_args = []
                if args:
                    pretty_args.extend(str(a) for a in args)
                if kwargs:
                    pretty_args.extend(
                        "%s=%s" % (k, v) for k, v in six.iteritems(kwargs))
                log.log(level, "%s(%s)", func_name, ", ".join(pretty_args))
            return func(self, *args, **kwargs)

        return wrapper

    return decorator