use of io.cdap.cdap.logging.appender.LogMessage in project cdap by caskdata.
the class LogAppenderLogProcessor method process.
@Override
public void process(Iterator<byte[]> loggingEventBytes) {
LoggingEventSerializer serializer = LOGGING_EVENT_SERIALIZER.get();
loggingEventBytes.forEachRemaining(bytes -> {
try {
ILoggingEvent iLoggingEvent = serializer.fromBytes(ByteBuffer.wrap(bytes));
LoggingContext loggingContext = LoggingContextHelper.getLoggingContext(iLoggingEvent.getMDCPropertyMap());
if (loggingContext == null) {
// This shouldn't happen
LOG.debug("Ignore logging event due to missing logging context: {}", iLoggingEvent);
return;
}
logAppender.append(new LogMessage(iLoggingEvent, loggingContext));
} catch (IOException e) {
LOG.warn("Ignore logging event due to decode failure: {}", e.getMessage());
LOG.debug("Ignore logging event stack trace", e);
}
});
}
use of io.cdap.cdap.logging.appender.LogMessage in project cdap by caskdata.
the class LogBufferRecoveryServiceTest method createLoggingEvent.
private ILoggingEvent createLoggingEvent(String loggerName, Level level, String message, long timestamp, LoggingContext loggingContext) {
LoggingEvent event = new LoggingEvent();
event.setLevel(level);
event.setLoggerName(loggerName);
event.setMessage(message);
event.setTimeStamp(timestamp);
return new LogMessage(event, loggingContext);
}
use of io.cdap.cdap.logging.appender.LogMessage in project cdap by caskdata.
the class KafkaLogProcessorPipelineTest method publishLog.
private void publishLog(String topic, Iterable<ILoggingEvent> events, LoggingContext context) {
KafkaPublisher.Preparer preparer = KAFKA_TESTER.getKafkaClient().getPublisher(KafkaPublisher.Ack.LEADER_RECEIVED, Compression.NONE).prepare(topic);
LoggingEventSerializer serializer = new LoggingEventSerializer();
for (ILoggingEvent event : events) {
preparer.add(ByteBuffer.wrap(serializer.toBytes(new LogMessage(event, context))), context.getLogPartition());
}
preparer.send();
}
use of io.cdap.cdap.logging.appender.LogMessage in project cdap by caskdata.
the class LogBufferReaderTest method createLoggingEvent.
private ILoggingEvent createLoggingEvent(String loggerName, Level level, String message, long timestamp, LoggingContext loggingContext) {
LoggingEvent event = new LoggingEvent();
event.setLevel(level);
event.setLoggerName(loggerName);
event.setMessage(message);
event.setTimeStamp(timestamp);
return new LogMessage(event, loggingContext);
}
use of io.cdap.cdap.logging.appender.LogMessage in project cdap by caskdata.
the class DistributedLogFrameworkTest method publishLog.
/**
* Publishes multiple log events.
*/
private void publishLog(String topic, LoggingContext context, Iterable<ILoggingEvent> events) {
KafkaPublisher.Preparer preparer = KAFKA_TESTER.getKafkaClient().getPublisher(KafkaPublisher.Ack.LEADER_RECEIVED, Compression.NONE).prepare(topic);
LoggingEventSerializer serializer = new LoggingEventSerializer();
for (ILoggingEvent event : events) {
preparer.add(ByteBuffer.wrap(serializer.toBytes(new LogMessage(event, context))), context.getLogPartition());
}
preparer.send();
}
Aggregations