001
002/*
003 * Copyright 2023 the original author or authors.
004 * <p>
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 * <p>
009 * https://www.apache.org/licenses/LICENSE-2.0
010 * <p>
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package de.cuioss.tools.logging;
018
019import java.util.function.Supplier;
020
021/**
022 * Provides additional information for simplifying logging
023 *
024 * @author Oliver Wolff
025 *
026 */
027public interface LogRecord {
028
029    /**
030     * @return the prefix for identifying the log-entry, e.g. 'CUI'
031     */
032    String getPrefix();
033
034    /**
035     * @return the identifier for the concrete entry, e.g. '100'
036     */
037    Integer getIdentifier();
038
039    /**
040     * @return The message template for creating the log-message
041     */
042    String getTemplate();
043
044    /**
045     * Returns a {@link Supplier} view on the formatter
046     *
047     * @param parameter optional, used for filling the template
048     * @return a {@link Supplier} view on the formatter
049     */
050    Supplier<String> supplier(Object... parameter);
051
052    /**
053     * Formats the template with the given object. <em>Important:</em> it implicitly
054     * prepends the identifier, e.g. "CUI-100: " in front of the created message.
055     *
056     * @param parameter optional, used for filling the template
057     * @return the formated String.
058     */
059    String format(Object... parameter);
060
061    /**
062     * @return the concatenated identifier String, e.g. CUI-100
063     */
064    String resolveIdentifierString();
065
066}