package com.ecep.contract;

import java.util.logging.Level;

public interface MessageHolder {
    void addMessage(Level level, String message);

    default void error(String message) {
        addMessage(Level.SEVERE, message);
    }

    default void warn(String message) {
        addMessage(Level.WARNING, message);
    }

    default void info(String message) {
        addMessage(Level.INFO, message);
    }

    default void debug(String message) {
        addMessage(Level.FINE, message);
    }

    default MessageHolder sub(String prefix) {
        return new MessageHolder() {
            @Override
            public void addMessage(Level level, String message) {
                MessageHolder.this.addMessage(level, prefix + message);
            }
        };
    }
}
