All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkiverse.googlecloudservices.logging.runtime.format.JsonHandler Maven / Gradle / Ivy

package io.quarkiverse.googlecloudservices.logging.runtime.format;

import java.util.Map;
import java.util.logging.ErrorManager;

import org.jboss.logmanager.ExtLogRecord;

import com.google.cloud.logging.Payload;

import io.quarkiverse.googlecloudservices.logging.runtime.LoggingConfiguration;
import io.quarkiverse.googlecloudservices.logging.runtime.TraceInfo;
import io.quarkiverse.googlecloudservices.logging.runtime.ecs.EscJsonFormat;

public class JsonHandler implements InternalHandler {

    private final EscJsonFormat jsonFormat;

    public JsonHandler(LoggingConfiguration config, ErrorManager errorManager) {
        this.jsonFormat = createJsonFormatter(config, errorManager);
    }

    private EscJsonFormat createJsonFormatter(LoggingConfiguration config, ErrorManager errorManager) {
        EscJsonFormat form = new EscJsonFormat();
        form.init(config, errorManager);
        return form;
    }

    @Override
    public Payload transform(ExtLogRecord record, TraceInfo trace) {
        Map json = jsonFormat.format(record, trace);
        return json == null ? null : Payload.JsonPayload.of(json);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy