package com.yahoo.vespa.hosted.node.admin.util;

import com.yahoo.log.LogLevel;
import com.yahoo.vespa.hosted.node.admin.docker.ContainerName;

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

/**
 * @author valerijf
 */
public class PrefixLogger {
    private String prefix;
    private Logger logger;

    private PrefixLogger(Class clazz, String prefix) {
        this.logger = Logger.getLogger(clazz.getName());
        this.prefix = prefix + ": ";
    }

    public static PrefixLogger getNodeAdminLogger(Class clazz) {
        return new PrefixLogger(clazz, "NodeAdmin");
    }

    public static PrefixLogger getNodeAgentLogger(Class clazz, ContainerName containerName) {
        return new PrefixLogger(clazz, "NodeAgent-" + containerName.asString());
    }

    private void log(Level level, String message, Throwable thrown) {
        logger.log(level, prefix + message, thrown);
    }

    private void log(Level level, String message) {
        logger.log(level, prefix + message);
    }


    public void info(String message) {
        log(LogLevel.INFO, message);
    }

    public void info(String message, Throwable thrown) {
        log(LogLevel.INFO, message, thrown);
    }

    public void error(String message) {
        log(LogLevel.ERROR, message);
    }

    public void error(String message, Throwable thrown) {
        log(LogLevel.ERROR, message, thrown);
    }

    public void warning(String message) {
        log(LogLevel.WARNING, message);
    }

    public void warning(String message, Throwable thrown) {
        log(LogLevel.WARNING, message, thrown);
    }
}

@@ -325,16 +325,20 @@
  private
+ %3CT%3E
  PrefixL
@@ -340,32 +340,35 @@
 efixLogger(Class
+%3CT%3E
  clazz, String p
@@ -486,32 +486,36 @@
    public static
+ %3CT%3E
  PrefixLogger ge
@@ -532,24 +532,27 @@
 Logger(Class
+%3CT%3E
  clazz) %7B%0A  
@@ -626,16 +626,20 @@
 c static
+ %3CT%3E
  PrefixL
@@ -668,16 +668,19 @@
 er(Class
+%3CT%3E
  clazz, 

Fix missing type arguments for generic class java.lang.Class<T>