private static LogProtocol.LogMessage toLogRequestMessage(LogMessage logMessage) {
        Instant timestamp = logMessage.getTimestamp();
        long timestampNanos = timestamp.getEpochSecond() * 1_000_000_000L + timestamp.getNano();
        return LogProtocol.LogMessage.newBuilder()
                .setTimeNanos(timestampNanos)
                .setHostname(logMessage.getHost())
                .setProcessId((int) logMessage.getProcessId())
                .setThreadId((int) logMessage.getThreadId().orElse(0))
                .setService(logMessage.getService())
                .setComponent(logMessage.getComponent())
                .setLevel(toLogMessageLevel(logMessage.getLevel()))
                .setPayload(logMessage.getPayload())
                .build();
    }
Utility class for serialization of log requests and responses.

@author bjorncs
logserver/src/main/java/ai/vespa/logserver/protocol/ProtobufSerialization.java