aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/vespa/streamingvisitors/tracing/LoggingTraceExporter.java
blob: 222ec285316c24e5301ee9863dfc504685e6b64e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.streamingvisitors.tracing;

import java.util.logging.Level;

import java.util.function.Supplier;
import java.util.logging.Logger;

/**
 * Trace exporter which dumps traces and their description as warning-entries in the Vespa log.
 */
public class LoggingTraceExporter implements TraceExporter {

    private static final Logger log = Logger.getLogger(LoggingTraceExporter.class.getName());

    @Override
    public void maybeExport(Supplier<TraceDescription> traceDescriptionSupplier) {
        var traceDescription = traceDescriptionSupplier.get();
        if (traceDescription.getTrace() != null) {
            log.log(Level.WARNING, String.format("%s: %s", traceDescription.getDescription(),
                    traceDescription.getTrace().toString()));
        }
    }

}