tikhomirov@295: /*
tikhomirov@456: * Copyright (c) 2011-2012 TMate Software Ltd
tikhomirov@295: *
tikhomirov@295: * This program is free software; you can redistribute it and/or modify
tikhomirov@295: * it under the terms of the GNU General Public License as published by
tikhomirov@295: * the Free Software Foundation; version 2 of the License.
tikhomirov@295: *
tikhomirov@295: * This program is distributed in the hope that it will be useful,
tikhomirov@295: * but WITHOUT ANY WARRANTY; without even the implied warranty of
tikhomirov@295: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
tikhomirov@295: * GNU General Public License for more details.
tikhomirov@295: *
tikhomirov@295: * For information on how to redistribute this software under
tikhomirov@295: * the terms of a license other than GNU General Public License
tikhomirov@295: * contact TMate Software at support@hg4j.com
tikhomirov@295: */
tikhomirov@295: package org.tmatesoft.hg.util;
tikhomirov@295:
tikhomirov@295:
tikhomirov@295: /**
tikhomirov@456: * Facility to dump various messages.
tikhomirov@295: *
tikhomirov@295: * Intention of this class is to abstract away almost any log facility out there clients might be using with the Hg4J library,
tikhomirov@295: * not to be a full-fledged logging facility of its own.
tikhomirov@295: *
tikhomirov@295: * Implementations may wrap platform- or application-specific loggers, e.g. {@link java.util.logging.Logger} or
tikhomirov@295: * org.eclipse.core.runtime.ILog
tikhomirov@295: *
tikhomirov@295: * @author Artem Tikhomirov
tikhomirov@295: * @author TMate Software Ltd.
tikhomirov@295: */
tikhomirov@295: public interface LogFacility {
tikhomirov@456:
tikhomirov@456: public enum Severity {
tikhomirov@456: Debug, Info, Warn, Error // order is important
tikhomirov@456: }
tikhomirov@295:
tikhomirov@456: /**
tikhomirov@456: * Effective way to avoid attempts to construct debug dumps when they are of no interest. Basically, getLevel() < Info
tikhomirov@456: *
tikhomirov@456: * @return true
if interested in debug dumps
tikhomirov@456: */
tikhomirov@456: boolean isDebug();
tikhomirov@295:
tikhomirov@456: /**
tikhomirov@456: *
tikhomirov@456: * @return lowest (from {@link Severity#Debug} to {@link Severity#Error} active severity level
tikhomirov@456: */
tikhomirov@456: Severity getLevel();
tikhomirov@456:
tikhomirov@456: /**
tikhomirov@456: * Dump a message
tikhomirov@456: * @param src identifies source of the message, never null
tikhomirov@456: * @param severity one of predefined levels
tikhomirov@456: * @param format message format suitable for {@link String#format(String, Object...)}, never null
tikhomirov@456: * @param args optional arguments for the preceding format argument, may be null
tikhomirov@456: */
tikhomirov@456: void dump(Class> src, Severity severity, String format, Object... args);
tikhomirov@456:
tikhomirov@456: /**
tikhomirov@456: * Alternative to dump an exception
tikhomirov@456: *
tikhomirov@456: * @param src identifies source of the message, never null
tikhomirov@456: * @param severity one of predefined levels
tikhomirov@456: * @param th original exception, never null
tikhomirov@456: * @param message additional description of the error/conditions, may be null
tikhomirov@456: */
tikhomirov@456: void dump(Class> src, Severity severity, Throwable th, String message);
tikhomirov@295: }