used for sending warning and error logs to notification engine and to the console
490912
private void sendNotification(String errMessage, int errCode, String errType, boolean createNotification) {
        NotificationsDao notifications = storage.getNotificationsDao();
        Notification notification;

        if (errType == "warning") {
            logger.warning(errMessage); // send message to console
            if (createNotification) {
                notification = notification(WARNING_NOTIFICATION, errCode, errMessage);
                notifications.addNotification(notification);
            }
        } else if (errType == "error") {
            logger.error(errMessage); // send message to console
            if (createNotification) {
                notification = notification(ERROR_NOTIFICATION, errCode, errMessage);
                notifications.addNotification(notification);
            }
        } else if (errType == "info") {
            if (logger.isInfoEnabled()) {
                logger.info(errMessage); // send message to console
            }
        }
    }
997072
def send_notification(method, params)
      data = MessagePack.dump([2, method, params]).bytes
      ws.send(data)
    rescue => exc
      warn exc
      abort exc
    end
774259
def _emit_warning(cls, message):
        """"""
        sys.stderr.write('WARNING: {message}\n'.format(message=message))
        sys.stderr.flush()
357196
function notifyHandler(data) {
        const notification = Notification.parse(data);
        return evalBlacklist(notification)
            .then(() => {
                forum.emit('log', `Notification ${notification.id}: ${notification.label} received`);
    
                const ids = {
                    post: notification.postId,
                    topic: notification.topicId,
                    user: notification.userId,
                    pm: -1,
                    chat: -1
                };
                return notification.getText()
                    .then((postData) => forum.Commands.get(ids,
                        postData, (content) => forum.Post.reply(notification.topicId, notification.postId, content)))
                    .then((commands) => {
                        if (commands.commands.length === 0) {
                            debug(`Emitting events: 'notification' and 'notification:${notification.type}'`);
                            forum.emit(`notification:${notification.type}`, notification);
                            forum.emit('notification', notification);
                        }
                        return commands;
                    })
                    .then((commands) => commands.execute());
            }).catch((err) => {
                if (err === 'Ignoring notification') {
                //We do not process the notification, but we can continue with life
                    return Promise.resolve();
                }
                throw err;
            });
    }
1162892
public void warn(Throwable throwable, String msg, Object[] argArray) {
		logIfEnabled(Level.WARNING, throwable, msg, UNKNOWN_ARG, UNKNOWN_ARG, UNKNOWN_ARG, argArray);
	}
170792
function logWarning(terminal: Terminal, format: string, ...args: Array<mixed>): void {
  const str = util.format(format, ...args);
  terminal.log('%s: %s', chalk.yellow('warning'), str);
}
456096
function _log(message) {
    if (cluster.isMaster) {
        // write directly to the log file
        console.log(_format(message));
    }
    else {
        // send to master
        cluster.worker.process.send({
            type: "logging",
            data: {
                message: message,
                workerID: cluster.worker.id,
                pid: cluster.worker.process.pid
            }
        });
    }
}
177301
def warn_logging(logger):
    # type: (logging.Logger) -> Callable
    
    def showwarning(message, category, filename, lineno, file=None, line=None):
        logger.warning(message)
    return showwarning
188536
def logging_on(level=logging.WARNING):
    
    global _is_logging_on

    if not _is_logging_on:
        console = logging.StreamHandler()
        console.setFormatter(logging.Formatter("[%(levelname)s: %(asctime)s :"
                                               " %(name)s] %(message)s",
                                               '%Y-%m-%d %H:%M:%S'))
        console.setLevel(level)
        logging.getLogger('').addHandler(console)
        _is_logging_on = True

    log = logging.getLogger('')
    log.setLevel(level)
    for h in log.handlers:
        h.setLevel(level)
1146065
def emit_message(self, message, log_level):
        """"""
        self.log(message)
        if log_level == logging.ERROR:
            if self._error_msg_callback:
                self._error_msg_callback(message)
                return

        if log_level == logging.WARNING:
            if self._warning_msg_callback:
                self._warning_msg_callback(message)
                return

        if log_level == logging.INFO:
            if self._info_msg_callback:
                self._info_msg_callback(message)
                return

        if self._msg_callback:
            self._msg_callback(message)
562474
def listener(messages):
    
    for m in messages:
        if m.content_type == 'text':
            # print the sent message to the console
            print(str(m.chat.first_name) + " [" + str(m.chat.id) + "]: " + m.text)
758664
def notify(args):
    
    from jcvi.utils.iter import flatten

    valid_notif_methods.extend(available_push_api.keys())

    fromaddr = get_email_address(whoami="notifier")

    p = OptionParser(notify.__doc__)
    p.add_option("--method", default="email", choices=valid_notif_methods,
                 help="Specify the mode of notification [default: %default]")
    p.add_option("--subject", default="JCVI: job monitor",
                 help="Specify the subject of the notification message")
    p.set_email()

    g1 = OptionGroup(p, "Optional `push` parameters")
    g1.add_option("--api", default="pushover", \
                  choices=list(flatten(available_push_api.values())),
                  help="Specify API used to send the push notification")
    g1.add_option("--priority", default=0, type="int",
                  help="Message priority (-1 <= p <= 2) [default: %default]")
    g1.add_option("--timestamp", default=None, type="int", \
                  dest="timestamp", \
                  help="Message timestamp in unix format [default: %default]")
    p.add_option_group(g1)

    opts, args = p.parse_args(args)

    if len(args) == 0:
        logging.error("Please provide a brief message to be sent")
        sys.exit(not p.print_help())

    subject = opts.subject
    message = " ".join(args).strip()

    if opts.method == "email":
        toaddr = opts.email.split(",")   # TO address should be in a list
        for addr in toaddr:
            if not is_valid_email(addr):
                logging.debug("Email address `{0}` is not valid!".format(addr))
                sys.exit()
        send_email(fromaddr, toaddr, subject, message)
    else:
        pushnotify(subject, message, api=opts.api, priority=opts.priority, \
                   timestamp=opts.timestamp)
946026
function attachToConsole(log) {
    'use strict';
    console.error = function () {
        log({args: arguments, level: messageLevel.ERROR});
    };
    console.warn = function () {
        log({args: arguments, level: messageLevel.WARN});
    };
    console.info = function () {
        log({args: arguments, level: messageLevel.INFO});
    };
}
1360162
private void sendMessageToLogger(Level level, String message, Log log, Throwable e) {

        if (e == null) {
            if (level == Level.SEVERE) {
                log.error(message);
            } else if (level == Level.WARNING) {
                log.warn(message);
            } else if (level == Level.INFO) {
                log.info(message);
            } else if (level == Level.CONFIG) {
                log.info(message);
            } else if ((level == Level.FINE) || (level == Level.FINER) || (level == Level.FINEST)) {
                log.debug(message);
            } else {
                log.info(message);
            }
        } else {
            if (level == Level.SEVERE) {
                log.error(message, e);
            } else if (level == Level.WARNING) {
                log.warn(message, e);
            } else if (level == Level.INFO) {
                log.info(message, e);
            } else if (level == Level.CONFIG) {
                log.info(message, e);
            } else if ((level == Level.FINE) || (level == Level.FINER) || (level == Level.FINEST)) {
                log.debug(message, e);
            } else {
                log.info(message, e);
            }
        }
    }
201887
def warn (logname, msg, *args, **kwargs):
    
    log = logging.getLogger(logname)
    if log.isEnabledFor(logging.WARN):
        _log(log.warn, msg, args, **kwargs)
377625
function log(msg, type) {
	switch (type) {
	case 'error':
		fancyLog(`${PLUGINNAME}: ${colors.red(`Error, ${msg}`)}`);
		break;

	case 'warn':
		fancyLog(`${PLUGINNAME}: ${colors.yellow(`Warning, ${msg}`)}`);
		break;

	case 'info':
		fancyLog(`${PLUGINNAME}: ${colors.green(`Info, ${msg}`)}`);
		break;

	default:
		fancyLog(`${PLUGINNAME}: ${colors.green(`Info, ${msg}`)}`);
		break;
	}

}
253053
def handle_notification(self, msgtype, method, args, kwargs):
        """"""
        self.dispatch.call(method, args, kwargs)