final GelfMessageLevel messageLevel = level == null ? GelfMessageLevel.ALERT : GelfMessageLevel.fromNumericLevel(level);
final String fullMessage = (String) message.getField("message");
final String facility = (String) message.getField("facility");
final String forwarder = GelfOutput.class.getCanonicalName();
final GelfMessageBuilder builder = new GelfMessageBuilder(message.getMessage(), message.getSource())
.timestamp(timestamp.getMillis())
.level(messageLevel)
.additionalField("_forwarder", forwarder)
.additionalFields(message.getFields());
if (fullMessage != null) {
builder.fullMessage(fullMessage);
}
if (facility != null) {
builder.additionalField("_facility", facility);
}
return builder.build();
}