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

com.yahoo.vespa.hosted.provision.testutils.InMemoryProvisionLogger Maven / Gradle / Ivy

There is a newer version: 8.441.21
Show newest version
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.provision.testutils;

import com.yahoo.config.provision.ProvisionLogger;

import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * A logger which remembers all messages logged in addition to writing them to standard out.
 *
 * @author bratseth
 */
public class InMemoryProvisionLogger implements ProvisionLogger {

    private static final Logger LOG = Logger.getLogger(InMemoryProvisionLogger.class.getName());

    private final List systemLog = new ArrayList<>();
    private final List applicationLog = new ArrayList<>();

    @Override
    public void log(Level level, String message) {
        LOG.info("ProvisionLogger system " + level + ": " + message);
        systemLog.add(level + ": " + message);
    }

    @Override
    public void logApplicationPackage(Level level, String message) {
        LOG.info("ProvisionLogger application " + level + ": " + message);
        applicationLog.add(level + ": " + message);
    }

    public List systemLog() { return systemLog; }
    public List applicationLog() { return applicationLog; }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy