当前位置: 首页>>代码示例>>Java>>正文


Java SyslogIF.emergency方法代码示例

本文整理汇总了Java中org.productivity.java.syslog4j.SyslogIF.emergency方法的典型用法代码示例。如果您正苦于以下问题:Java SyslogIF.emergency方法的具体用法?Java SyslogIF.emergency怎么用?Java SyslogIF.emergency使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.productivity.java.syslog4j.SyslogIF的用法示例。


在下文中一共展示了SyslogIF.emergency方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendMessage

import org.productivity.java.syslog4j.SyslogIF; //导入方法依赖的package包/类
static public 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;
	}
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:32,代码来源:SyslogDefs.java

示例2: testMultipleSyslog

import org.productivity.java.syslog4j.SyslogIF; //导入方法依赖的package包/类
public void testMultipleSyslog() {
	FakeSyslogConfig config1 = new FakeSyslogConfig();
	FakeSyslog fake1 = (FakeSyslog) Syslog.createInstance("fake1", config1);

	FakeSyslogConfig config2 = new FakeSyslogConfig();
	FakeSyslog fake2 = (FakeSyslog) Syslog.createInstance("fake2", config2);

	MultipleSyslogConfig config = new MultipleSyslogConfig();
	config.addProtocol("fake1");
	config.addProtocol("fake2");
	
	SyslogIF syslog = Syslog.createInstance("multiple",config);
	
	assertEquals(0,fake1.total);
	assertEquals(0,fake2.total);
	
	syslog.debug("test");
	assertEquals(1,fake1.total);
	assertEquals(1,fake2.total);

	syslog.debug(new FakeSyslogMessage());
	assertEquals(1 + 2,fake1.total);
	assertEquals(1 + 2,fake2.total);

	syslog.info("test");
	assertEquals(1 + 2 + 4,fake1.total);
	assertEquals(1 + 2 + 4,fake2.total);
	
	syslog.info(new FakeSyslogMessage());
	assertEquals(1 + 2 + 4 + 8,fake1.total);
	assertEquals(1 + 2 + 4 + 8,fake2.total);
	
	syslog.notice("test");
	assertEquals(1 + 2 + 4 + 8 + 16,fake1.total);
	assertEquals(1 + 2 + 4 + 8 + 16,fake2.total);
	
	syslog.notice(new FakeSyslogMessage());
	assertEquals(1 + 2 + 4 + 8 + 16 + 32,fake1.total);
	assertEquals(1 + 2 + 4 + 8 + 16 + 32,fake2.total);

	syslog.warn("test");
	assertEquals(1 + 2 + 4 + 8 + 16 + 32 + 64,fake1.total);
	assertEquals(1 + 2 + 4 + 8 + 16 + 32 + 64,fake2.total);
	
	syslog.warn(new FakeSyslogMessage());
	assertEquals(1 + 2 + 4 + 8 + 16 + 32 + 64 + 128,fake1.total);
	assertEquals(1 + 2 + 4 + 8 + 16 + 32 + 64 + 128,fake2.total);

	syslog.error("test");
	assertEquals(1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 + 256,fake1.total);
	assertEquals(1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 + 256,fake2.total);
	
	syslog.error(new FakeSyslogMessage());
	assertEquals(1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 + 256 + 512,fake1.total);
	assertEquals(1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 + 256 + 512,fake2.total);

	syslog.critical("test");
	assertEquals(1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 + 256 + 512 + 1024,fake1.total);
	assertEquals(1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 + 256 + 512 + 1024,fake2.total);
	
	syslog.critical(new FakeSyslogMessage());
	assertEquals(1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 + 256 + 512 + 1024 + 2048,fake1.total);
	assertEquals(1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 + 256 + 512 + 1024 + 2048,fake2.total);

	syslog.alert("test");
	assertEquals(1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 + 256 + 512 + 1024 + 2048 + 4096,fake1.total);
	assertEquals(1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 + 256 + 512 + 1024 + 2048 + 4096,fake2.total);
	
	syslog.alert(new FakeSyslogMessage());
	assertEquals(1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 + 256 + 512 + 1024 + 2048 + 4096 + 8192,fake1.total);
	assertEquals(1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 + 256 + 512 + 1024 + 2048 + 4096 + 8192,fake2.total);

	syslog.emergency("test");
	assertEquals(1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 + 256 + 512 + 1024 + 2048 + 4096 + 8192 + 16384,fake1.total);
	assertEquals(1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 + 256 + 512 + 1024 + 2048 + 4096 + 8192 + 16384,fake2.total);
	
	syslog.emergency(new FakeSyslogMessage());
	assertEquals(1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 + 256 + 512 + 1024 + 2048 + 4096 + 8192 + 16384 + 32768,fake1.total);
	assertEquals(1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 + 256 + 512 + 1024 + 2048 + 4096 + 8192 + 16384 + 32768,fake2.total);
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:81,代码来源:MultipleSyslogCreateTest.java

示例3: sendMessage

import org.productivity.java.syslog4j.SyslogIF; //导入方法依赖的package包/类
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;
  }
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:48,代码来源:SyslogDefs.java

示例4: _testSendReceivePCIMessages

import org.productivity.java.syslog4j.SyslogIF; //导入方法依赖的package包/类
public void _testSendReceivePCIMessages(boolean sortEvents, boolean sortRecordedEvents){
	List events = new ArrayList();
	
	String protocol = getClientProtocol();
	
	SyslogIF syslog = getSyslog(protocol);

	PCISyslogMessage message = new PCISyslogMessage();
	message.setUserId("[TEST]");
	
	syslog.debug(message);
	events.add(message.createMessage());
	
	syslog.info(message);
	events.add(message.createMessage());
	
	syslog.notice(message);
	events.add(message.createMessage());
	
	syslog.warn(message);
	events.add(message.createMessage());
	
	syslog.error(message);
	events.add(message.createMessage());
	
	syslog.critical(message);
	events.add(message.createMessage());

	syslog.alert(message);
	events.add(message.createMessage());

	syslog.emergency(message);
	events.add(message.createMessage());

	syslog.log(SyslogConstants.LEVEL_INFO,message);
	events.add(message.createMessage());

	SyslogUtility.sleep(100);
	
	syslog.flush();
	
	verifySendReceive(events,sortEvents,sortRecordedEvents);
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:44,代码来源:AbstractNetSyslog4jTest.java

示例5: _testSendReceiveStructuredMessages

import org.productivity.java.syslog4j.SyslogIF; //导入方法依赖的package包/类
public void _testSendReceiveStructuredMessages(boolean sortEvents, boolean sortRecordedEvents){
	List events = new ArrayList();
	
	String protocol = getClientProtocol();
	
	SyslogIF syslog = getSyslog(protocol);

	this.server.getConfig().setUseStructuredData(true);

	Map m2 = new HashMap();
	m2.put("foo","bar");

	Map m1 = new HashMap();
	m1.put("testa",m2);
	
	StructuredSyslogMessageIF message = new StructuredSyslogMessage("[TEST]",m1,"testb");
	
	syslog.debug(message);
	events.add(message.createMessage());
	
	syslog.info(message);
	events.add(message.createMessage());
	
	syslog.notice(message);
	events.add(message.createMessage());
	
	syslog.warn(message);
	events.add(message.createMessage());
	
	syslog.error(message);
	events.add(message.createMessage());
	
	syslog.critical(message);
	events.add(message.createMessage());

	syslog.alert(message);
	events.add(message.createMessage());

	syslog.emergency(message);
	events.add(message.createMessage());

	syslog.log(SyslogConstants.LEVEL_INFO,message);
	events.add(message.createMessage());

	syslog.log(SyslogConstants.LEVEL_INFO,message.createMessage());
	events.add(message.createMessage());

	SyslogUtility.sleep(100);
	
	syslog.flush();
	
	verifySendReceive(events,sortEvents,sortRecordedEvents);

	this.server.getConfig().setUseStructuredData(false);
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:56,代码来源:AbstractNetSyslog4jTest.java


注:本文中的org.productivity.java.syslog4j.SyslogIF.emergency方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。