use of ch.qos.logback.classic.spi.ILoggingEvent in project cdap by caskdata.
the class DistributedLogFrameworkTest method createLoggingEvent.
/**
* Creates an {@link ILoggingEvent}.
*/
private ILoggingEvent createLoggingEvent(String loggerName, Level level, String message, long timestamp) {
LoggingEvent event = new LoggingEvent();
event.setLevel(level);
event.setLoggerName(loggerName);
event.setMessage(message);
event.setTimeStamp(timestamp);
return event;
}
use of ch.qos.logback.classic.spi.ILoggingEvent in project cdap by caskdata.
the class LoggingEventSerializerTest method testEmptySerialization.
@Test
public void testEmptySerialization() throws Exception {
Logger logger = LoggerFactory.getLogger(LoggingEventSerializerTest.class);
LoggingEventSerializer serializer = new LoggingEventSerializer();
ch.qos.logback.classic.spi.LoggingEvent iLoggingEvent = new ch.qos.logback.classic.spi.LoggingEvent(getClass().getName(), (ch.qos.logback.classic.Logger) logger, Level.ERROR, "message", null, null);
iLoggingEvent.setThreadName("thread-1");
iLoggingEvent.setTimeStamp(10000000L);
// Serialize
ILoggingEvent event = new LogMessage(iLoggingEvent, LoggingContextAccessor.getLoggingContext());
byte[] serializedBytes = serializer.toBytes(event);
// De-serialize
ILoggingEvent actualEvent = serializer.fromBytes(ByteBuffer.wrap(serializedBytes));
assertLoggingEventEquals(iLoggingEvent, actualEvent);
}
use of ch.qos.logback.classic.spi.ILoggingEvent in project cdap by caskdata.
the class LoggingEventTest method testEmptySerialize.
@Test
public void testEmptySerialize() throws Exception {
Logger logger = LoggerFactory.getLogger(LoggingEventTest.class);
ch.qos.logback.classic.spi.LoggingEvent iLoggingEvent = new ch.qos.logback.classic.spi.LoggingEvent(getClass().getName(), (ch.qos.logback.classic.Logger) logger, Level.ERROR, null, null, null);
LoggingEventSerializer serializer = new LoggingEventSerializer();
byte[] encoded = serializer.toBytes(new LogMessage(iLoggingEvent, LoggingContextAccessor.getLoggingContext()));
ILoggingEvent decodedEvent = serializer.fromBytes(ByteBuffer.wrap(encoded));
LoggingEventSerializerTest.assertLoggingEventEquals(iLoggingEvent, decodedEvent);
}
use of ch.qos.logback.classic.spi.ILoggingEvent in project cdap by caskdata.
the class LogPipelineConfigurator method buildInterpreter.
@Override
protected void buildInterpreter() {
super.buildInterpreter();
RuleStore ruleStore = interpreter.getRuleStore();
ruleStore.addRule(new Pattern("configuration/contextName"), new ContextConfigAction(cConf));
ruleStore.addRule(new Pattern("configuration/appender"), new WrapAppenderAction<ILoggingEvent>());
}
use of ch.qos.logback.classic.spi.ILoggingEvent in project cdap by caskdata.
the class LogLocation method readToEndSyncPosition.
/**
* Read current block in Avro file from current block sync marker to next block sync marker
*/
private List<LogEvent> readToEndSyncPosition(DataFileReader<GenericRecord> dataFileReader, Filter logFilter, long fromTimeMs, long endSyncPosition) throws IOException {
List<LogEvent> logSegment = new ArrayList<>();
long currentSyncPosition = dataFileReader.previousSync();
// or read until endSyncPosition has been reached
while (dataFileReader.hasNext() && (endSyncPosition == -1 || (currentSyncPosition < endSyncPosition))) {
ILoggingEvent loggingEvent = new LoggingEvent(dataFileReader.next());
loggingEvent.prepareForDeferredProcessing();
// Stop when reached fromTimeMs
if (loggingEvent.getTimeStamp() > fromTimeMs) {
break;
}
if (logFilter.match(loggingEvent)) {
logSegment.add(new LogEvent(loggingEvent, new LogOffset(LogOffset.INVALID_KAFKA_OFFSET, loggingEvent.getTimeStamp())));
}
currentSyncPosition = dataFileReader.previousSync();
}
return logSegment;
}
Aggregations