Java 类ch.qos.logback.classic.spi.LoggingEventVO 实例源码

项目:bartleby    文件:RemoteAppenderStreamClientTest.java   
@Before
public void setUp() throws Exception {
  LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();

  appender = new MockAppender();
  appender.start();

  logger = lc.getLogger(getClass());
  logger.addAppender(appender);

  event = new LoggingEvent(logger.getName(), logger, 
      Level.DEBUG, "test message", null, new Object[0]);

  LoggingEventVO eventVO = LoggingEventVO.build(event);

  ByteArrayOutputStream bos = new ByteArrayOutputStream();
  ObjectOutputStream oos = new ObjectOutputStream(bos);
  oos.writeObject(eventVO);
  oos.close();

  ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
  client = new RemoteAppenderStreamClient("some client ID", bis);
  client.setLoggerContext(lc);
}
项目:bartleby    文件:SocketReceiverTest.java   
@Test
public void testDispatchEventForEnabledLevel() throws Exception {
  receiver.setRemoteHost(InetAddress.getLocalHost().getHostName());
  receiver.setPort(6000);
  receiver.start();
  assertTrue(receiver.awaitConnectorCreated(DELAY));
  Socket socket = serverSocket.accept();

  ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());

  logger.setLevel(Level.DEBUG);
  ILoggingEvent event = new LoggingEvent(logger.getName(), logger, 
      Level.DEBUG, "test message", null, new Object[0]);

  LoggingEventVO eventVO = LoggingEventVO.build(event);
  oos.writeObject(eventVO);
  oos.flush();

  ILoggingEvent rcvdEvent = appender.awaitAppend(DELAY);
  assertNotNull(rcvdEvent);
  assertEquals(event.getLoggerName(), rcvdEvent.getLoggerName());
  assertEquals(event.getLevel(), rcvdEvent.getLevel());
  assertEquals(event.getMessage(), rcvdEvent.getMessage());
}
项目:bartleby    文件:SocketReceiverTest.java   
@Test
public void testNoDispatchEventForDisabledLevel() throws Exception {
  receiver.setRemoteHost(InetAddress.getLocalHost().getHostName());
  receiver.setPort(6000);
  receiver.start();
  assertTrue(receiver.awaitConnectorCreated(DELAY));
  Socket socket = serverSocket.accept();

  ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());

  logger.setLevel(Level.INFO);
  ILoggingEvent event = new LoggingEvent(logger.getName(), logger, 
      Level.DEBUG, "test message", null, new Object[0]);

  LoggingEventVO eventVO = LoggingEventVO.build(event);
  oos.writeObject(eventVO);
  oos.flush();

  assertNull(appender.awaitAppend(DELAY));
}
项目:bartleby    文件:LoggingEventPreSerializationTransformer.java   
public Serializable transform(ILoggingEvent event) {
  if(event == null) {
    return null;
  }
  if (event instanceof LoggingEvent) {
    return LoggingEventVO.build(event);
  } else if (event instanceof LoggingEventVO) {
    return (LoggingEventVO)  event;
  } else {
    throw new IllegalArgumentException("Unsupported type "+event.getClass().getName());
  }
}
项目:bartleby    文件:ServerSocketReceiverFunctionalTest.java   
@Test
public void testLogEventFromClient() throws Exception {
  ILoggingEvent event = new LoggingEvent(logger.getName(), logger, 
      Level.DEBUG, "test message", null, new Object[0]);
  Socket socket = new Socket(InetAddress.getLocalHost(), 
      serverSocket.getLocalPort());

  try {      
    LoggingEventVO eventVO = LoggingEventVO.build(event);

    ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());
    for (int i = 0; i < EVENT_COUNT; i++) {
      oos.writeObject(eventVO);
    }

    oos.writeObject(eventVO);
    oos.flush();
  }
  finally {
    socket.close();
  }

  ILoggingEvent rcvdEvent = appender.awaitAppend(SHUTDOWN_DELAY);
  assertNotNull(rcvdEvent);
  assertEquals(event.getLoggerName(), rcvdEvent.getLoggerName());
  assertEquals(event.getLevel(), rcvdEvent.getLevel());
  assertEquals(event.getMessage(), rcvdEvent.getMessage());
}
项目:logging-extensions    文件:LoggerNameInMessageTransformer.java   
public Serializable transform(ILoggingEvent event) {
    if (event == null) {
        return null;
    }

    if (event instanceof LoggingEvent) {
        return LoggingEventVO.build(new LoggingEventWithLoggerNameInMessage(event));
    } else if (event instanceof LoggingEventVO) {
        return (LoggingEventVO) event;
    } else {
        throw new IllegalArgumentException("Unsupported type " + event.getClass().getName());
    }
}
项目:SORCER    文件:RemoteLoggerClient.java   
/**
 * Publishes the logging event to RemoteLogger using cashed proxy. Retries once on failure using {@link #publishNoRetry(java.util.List)}.
 *
 * @param vos the logging events to publish
 */
private void publishRetry(List<LoggingEventVO> vos) {
    try {
        remoteLogger.publish(vos);
    } catch (RemoteException e) {
        log.debug("Could not publish logging event, retrying", e);
        publishNoRetry(vos);
    }
}
项目:SORCER    文件:RemoteLoggerClient.java   
/**
 * Gets a new RemoteLogger proxy and if it's available, publishes the logging event to it.
 *
 * @param vos the logging events to publish
 */
private void publishNoRetry(List<LoggingEventVO> vos) {
    Object o = Accessor.get().getService(null, RemoteLogger.class);
    remoteLogger = (RemoteLogger)o;
    if (remoteLogger != null)
        try {
            remoteLogger.publish(vos);
        } catch (RemoteException e) {
            log.debug("Could not publish logging event", e);
            remoteLogger = null;
        }
}
项目:SORCER    文件:RemoteLoggerClient.java   
private static List<LoggingEventVO> vo(List<ILoggingEvent> loggingEvents) {
    List<LoggingEventVO> result = new ArrayList<LoggingEventVO>();
    for (ILoggingEvent event : loggingEvents)
        if (event instanceof LoggingEventVO)
            result.add((LoggingEventVO) event);
        else
            result.add(LoggingEventVO.build(event));
    return result;
}
项目:bartleby    文件:TrivialLoggingEventVOBuilder.java   
public Object build(int i) {
  TrivialLoggingEventBuilder loggingEventBuilder = new TrivialLoggingEventBuilder();
  LoggingEvent event = (LoggingEvent) loggingEventBuilder.build(i);

  return LoggingEventVO.build(event);
}
项目:logging-extensions    文件:UDPLogbackAppender.java   
private LoggingEventVO buildLoggingEventVO(ILoggingEvent originalEventObject) {
    final ILoggingEvent adjustedEvent = sendLoggerNameInMessage
            ? new LoggingEventWithLoggerNameInMessage(originalEventObject)
            : originalEventObject;
    return LoggingEventVO.build(adjustedEvent);
}
项目:SORCER    文件:RemoteLoggerManager.java   
public void publish(List<LoggingEventVO> loggingEvents) {
    for (LoggingEventVO vo : loggingEvents)
        publish(vo);
}
项目:SORCER    文件:RemoteLogger.java   
public void publish(List<LoggingEventVO> record) throws RemoteException;