Java Code Examples for org.productivity.java.syslog4j.SyslogConstants#LEVEL_CRITICAL

The following examples show how to use org.productivity.java.syslog4j.SyslogConstants#LEVEL_CRITICAL . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SyslogUtility.java    From syslog4j with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static final String getLevelString(int level) {
	switch(level) {
		case SyslogConstants.LEVEL_DEBUG: return "DEBUG";
		case SyslogConstants.LEVEL_INFO: return "INFO";
		case SyslogConstants.LEVEL_NOTICE: return "NOTICE";
		case SyslogConstants.LEVEL_WARN: return "WARN";
		case SyslogConstants.LEVEL_ERROR: return "ERROR";
		case SyslogConstants.LEVEL_CRITICAL: return "CRITICAL";
		case SyslogConstants.LEVEL_ALERT: return "ALERT";
		case SyslogConstants.LEVEL_EMERGENCY: return "EMERGENCY";
		
		default:
			return "UNKNOWN";
	}
}
 
Example 2
Source File: Log4jSyslogBackLogHandler.java    From syslog4j with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected static Level getLog4jLevel(int level) {
	switch(level) {
		case SyslogConstants.LEVEL_DEBUG: 		return Level.DEBUG;
		case SyslogConstants.LEVEL_INFO: 		return Level.INFO;
		case SyslogConstants.LEVEL_NOTICE: 		return Level.INFO;
		case SyslogConstants.LEVEL_WARN: 		return Level.WARN;
		case SyslogConstants.LEVEL_ERROR: 		return Level.ERROR;
		case SyslogConstants.LEVEL_CRITICAL: 	return Level.ERROR;
		case SyslogConstants.LEVEL_ALERT: 		return Level.ERROR;
		case SyslogConstants.LEVEL_EMERGENCY: 	return Level.FATAL;
		
		default:
			return Level.WARN;
	}
}
 
Example 3
Source File: MultipleSyslogCreateTest.java    From syslog4j with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void log(int level, String message) {
	if (SyslogConstants.LEVEL_DEBUG == level) { debug(message); }
	if (SyslogConstants.LEVEL_INFO == level) { info(message); }
	if (SyslogConstants.LEVEL_NOTICE == level) { notice(message); }
	if (SyslogConstants.LEVEL_WARN == level) { warn(message); }
	if (SyslogConstants.LEVEL_ERROR == level) { error(message); }
	if (SyslogConstants.LEVEL_CRITICAL == level) { critical(message); }
	if (SyslogConstants.LEVEL_ALERT == level) { alert(message); }
	if (SyslogConstants.LEVEL_EMERGENCY == level) { emergency(message); }
}
 
Example 4
Source File: MultipleSyslogCreateTest.java    From syslog4j with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void log(int level, SyslogMessageIF message) {
	if (SyslogConstants.LEVEL_DEBUG == level) { debug(message); }
	if (SyslogConstants.LEVEL_INFO == level) { info(message); }
	if (SyslogConstants.LEVEL_NOTICE == level) { notice(message); }
	if (SyslogConstants.LEVEL_WARN == level) { warn(message); }
	if (SyslogConstants.LEVEL_ERROR == level) { error(message); }
	if (SyslogConstants.LEVEL_CRITICAL == level) { critical(message); }
	if (SyslogConstants.LEVEL_ALERT == level) { alert(message); }
	if (SyslogConstants.LEVEL_EMERGENCY == level) { emergency(message); }
}
 
Example 5
Source File: SyslogHandlerTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Convert JBoss Logger.Level to Syslog log level.
 *
 * @param jbossLogLevel
 *
 * @return
 */
private int getSyslogLevel(Level jbossLogLevel) {
    final int result;
    switch (jbossLogLevel) {
        case TRACE:
        case DEBUG:
            result = SyslogConstants.LEVEL_DEBUG;
            break;
        case INFO:
            result = SyslogConstants.LEVEL_INFO;
            break;
        case WARN:
            result = SyslogConstants.LEVEL_WARN;
            break;
        case ERROR:
            result = SyslogConstants.LEVEL_ERROR;
            break;
        case FATAL:
            result = SyslogConstants.LEVEL_EMERGENCY;
            break;
        default:
            // unexpected
            result = SyslogConstants.LEVEL_CRITICAL;
            break;
    }
    return result;
}
 
Example 6
Source File: SyslogDefs.java    From hop with Apache License 2.0 4 votes vote down vote up
public static void sendMessage( SyslogIF syslog, int priority, String message, boolean addTimestamp,
                                String pattern, boolean addHostName ) {

  String messageString = message;

  // Do we need to add hostname?
  if ( addHostName ) {
    messageString = Const.getHostname() + " " + messageString;
  }

  // Do we need to add timestamp
  if ( addTimestamp ) {
    SimpleDateFormat dateFormat = new SimpleDateFormat( pattern );
    dateFormat.setTimeZone( TimeZone.getDefault() );
    messageString = dateFormat.format( Calendar.getInstance().getTime() ) + " : " + messageString;
  }

  // send message
  switch ( priority ) {
    case SyslogConstants.LEVEL_EMERGENCY:
      syslog.emergency( messageString );
      break;
    case SyslogConstants.LEVEL_ALERT:
      syslog.alert( messageString );
      break;
    case SyslogConstants.LEVEL_CRITICAL:
      syslog.critical( messageString );
      break;
    case SyslogConstants.LEVEL_ERROR:
      syslog.error( messageString );
      break;
    case SyslogConstants.LEVEL_WARN:
      syslog.warn( messageString );
      break;
    case SyslogConstants.LEVEL_NOTICE:
      syslog.notice( messageString );
      break;
    case SyslogConstants.LEVEL_INFO:
      syslog.info( messageString );
      break;
    case SyslogConstants.LEVEL_DEBUG:
      syslog.debug( messageString );
      break;
    default:
      break;
  }
}
 
Example 7
Source File: SyslogDefs.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public static void sendMessage( SyslogIF syslog, int priority, String message, boolean addTimestamp,
  String pattern, boolean addHostName ) {

  String messageString = message;

  // Do we need to add hostname?
  if ( addHostName ) {
    messageString = Const.getHostname() + " " + messageString;
  }

  // Do we need to add timestamp
  if ( addTimestamp ) {
    SimpleDateFormat dateFormat = new SimpleDateFormat( pattern );
    dateFormat.setTimeZone( TimeZone.getDefault() );
    messageString = dateFormat.format( Calendar.getInstance().getTime() ) + " : " + messageString;
  }

  // send message
  switch ( priority ) {
    case SyslogConstants.LEVEL_EMERGENCY:
      syslog.emergency( messageString );
      break;
    case SyslogConstants.LEVEL_ALERT:
      syslog.alert( messageString );
      break;
    case SyslogConstants.LEVEL_CRITICAL:
      syslog.critical( messageString );
      break;
    case SyslogConstants.LEVEL_ERROR:
      syslog.error( messageString );
      break;
    case SyslogConstants.LEVEL_WARN:
      syslog.warn( messageString );
      break;
    case SyslogConstants.LEVEL_NOTICE:
      syslog.notice( messageString );
      break;
    case SyslogConstants.LEVEL_INFO:
      syslog.info( messageString );
      break;
    case SyslogConstants.LEVEL_DEBUG:
      syslog.debug( messageString );
      break;
    default:
      break;
  }
}