001: /*
002: * Enhydra Java Application Server Project
003: *
004: * The contents of this file are subject to the Enhydra Public License
005: * Version 1.1 (the "License"); you may not use this file except in
006: * compliance with the License. You may obtain a copy of the License on
007: * the Enhydra web site ( http://www.enhydra.org/ ).
008: *
009: * Software distributed under the License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
011: * the License for the specific terms governing rights and limitations
012: * under the License.
013: *
014: * The Initial Developer of the Enhydra Application Server is Lutris
015: * Technologies, Inc. The Enhydra Application Server and portions created
016: * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
017: * All Rights Reserved.
018: *
019: * Contributor(s):
020: *
021: * $Id: LogChannel.java,v 1.2 2006-06-15 13:40:47 sinisa Exp $
022: */
023: package com.lutris.logging;
024:
025: /**
026: * Interface of a channel associated with a logging facility. All messages
027: * for the facility are written using a channel.
028: *
029: * @author Mark Diekhans
030: * @see com.lutris.logging.Logger
031: * @see com.lutris.logging.LogWriter
032: */
033: public interface LogChannel {
034:
035: /**
036: * Determine if logging is enabled for the specified level. This
037: * is useful to prevent a series of unnecessary logging calls,
038: * as often encountered with debug logging, or a call where generating
039: * the message is expensive.
040: *
041: * @param level Numeric level that is to be checked.
042: * @return <CODE>true</CODE> if enabled, <CODE>false</CODE> if not
043: * enabled.
044: */
045: boolean isEnabled(int level);
046:
047: /**
048: * Determine if logging is enabled for the specified level. This
049: * is useful to prevent a series of unnecessary logging calls,
050: * as often encountered with debug logging, or a call where generating
051: * the message is expensive.
052: *
053: * @param level Symbolic level that is to be checked.
054: * @return <CODE>true</CODE> if enabled, <CODE>false</CODE> if not
055: * enabled.
056: */
057: boolean isEnabled(String level);
058:
059: /**
060: * Convert a symbolic level to an integer identifier.
061: *
062: * @param level Symbolic level to convert
063: * @return The numeric level identifier
064: */
065: int getLevel(String level);
066:
067: /**
068: * Create a LogWrite associated with a particular level. This
069: * is often an easier object to use than a LogChannel if limited
070: * levels are needed.
071: *
072: * @param level Symbolic level that is to be checked.
073: * @return A log writer object.
074: */
075: LogWriter getLogWriter(String level);
076:
077: /**
078: * Create a LogWrite associated with a particular level. This
079: * is often an easier object to use than a LogChannel if limited
080: * levels are needed.
081: *
082: * @param level Numeric level that is to be checked.
083: * @return A log writer object.
084: */
085: LogWriter getLogWriter(int level);
086:
087: /**
088: * Write a string to the log file.
089: *
090: * @param level Numeric level the message is associated with.
091: * @param msg The message to log.
092: */
093: void write(int level, String msg);
094:
095: /**
096: * Write a string to the log file.
097: *
098: * @param level Symbolic level the message is associated with.
099: * @param msg The message to log.
100: */
101: void write(String level, String msg);
102:
103: /**
104: * Write a string and exception to the log file.
105: *
106: * @param level Numeric level the message is associated with.
107: * @param msg The message to log.
108: * @param throwable Exception or error to log.
109: */
110: void write(int level, String msg, Throwable throwable);
111:
112: /**
113: * Write a string and exception to the log file.
114: *
115: * @param level Symbolic level the message is associated with.
116: * @param msg The message to log.
117: * @param throwable Exception or error to log.
118: */
119: void write(String level, String msg, Throwable throwable);
120: }
|