00001 /******************************************************************************* 00002 00003 @file ILogger.d 00004 00005 Copyright (C) 2004 Kris Bell 00006 00007 This software is provided 'as-is', without any express or implied 00008 warranty. In no event will the authors be held liable for damages 00009 of any kind arising from the use of this software. 00010 00011 Permission is hereby granted to anyone to use this software for any 00012 purpose, including commercial applications, and to alter it and/or ` 00013 redistribute it freely, subject to the following restrictions: 00014 00015 1. The origin of this software must not be misrepresented; you must 00016 not claim that you wrote the original software. If you use this 00017 software in a product, an acknowledgment within documentation of 00018 said product would be appreciated but is not required. 00019 00020 2. Altered source versions must be plainly marked as such, and must 00021 not be misrepresented as being the original software. 00022 00023 3. This notice may not be removed or altered from any distribution 00024 of the source. 00025 00026 00027 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00028 00029 00030 @version Initial version, May 2004 00031 @author Kris 00032 00033 00034 *******************************************************************************/ 00035 00036 module mango.log.model.ILogger; 00037 00038 public import mango.log.model.ILevel; 00039 00040 /******************************************************************************* 00041 00042 This is the primary API to the log package. Use the two static 00043 methods to access and/or create Logger instances, and the other 00044 methods to modify specific Logger attributes. 00045 00046 See <A HREF="http://logging.apache.org/log4j/docs/documentation.html">this page</A> 00047 for the official Log4J documentation. Mango.log closely follows 00048 both the API and the behaviour as documented at the official site. 00049 00050 *******************************************************************************/ 00051 00052 interface ILogger : ILevel 00053 { 00054 /*********************************************************************** 00055 00056 Add a trace messages. This is called 'debug' in Log4J but 00057 that is a reserved word in the D language. This needs some 00058 more thought. 00059 00060 ***********************************************************************/ 00061 00062 void trace (char[] msg); 00063 00064 /*********************************************************************** 00065 00066 Add an info message 00067 00068 ***********************************************************************/ 00069 00070 void info (char[] msg); 00071 00072 /*********************************************************************** 00073 00074 Add a warning message 00075 00076 ***********************************************************************/ 00077 00078 void warn (char[] msg); 00079 00080 /*********************************************************************** 00081 00082 Add an error message 00083 00084 ***********************************************************************/ 00085 00086 void error (char[] msg); 00087 00088 /*********************************************************************** 00089 00090 Add a fatal message 00091 00092 ***********************************************************************/ 00093 00094 void fatal (char[] msg); 00095 00096 /*********************************************************************** 00097 00098 Return the name of this Logger 00099 00100 ***********************************************************************/ 00101 00102 char[] getName (); 00103 00104 /*********************************************************************** 00105 00106 Return the current level assigned to this logger 00107 00108 ***********************************************************************/ 00109 00110 Level getLevel (); 00111 00112 /*********************************************************************** 00113 00114 Set the activity level of this logger. Levels control how 00115 much information is emitted during runtime, and relate to 00116 each other as follows: 00117 00118 Trace < Info < Warn < Error < Fatal < None 00119 00120 That is, if the level is set to Error, only calls to the 00121 error() and fatal() methods will actually produce output: 00122 all others will be inhibited. 00123 00124 Note that Log4J is a hierarchical environment, and each 00125 logger defaults to inheriting a level from its parent. 00126 00127 00128 ***********************************************************************/ 00129 00130 void setLevel (Level level); 00131 00132 /*********************************************************************** 00133 00134 same as setLevel (Level), but with additional control over 00135 whether the children are forced to accept the changed level 00136 or not. If 'force' is false, then children adopt the parent 00137 level only if they have their own level set to Level.None 00138 00139 ***********************************************************************/ 00140 00141 void setLevel (Level level, bool force); 00142 00143 /*********************************************************************** 00144 00145 Is this logger enabled for the provided level? 00146 00147 ***********************************************************************/ 00148 00149 bool isEnabled (Level level); 00150 00151 /*********************************************************************** 00152 00153 Return whether this logger uses additive appenders or not. 00154 See setAdditive(). 00155 00156 ***********************************************************************/ 00157 00158 bool isAdditive (); 00159 00160 /*********************************************************************** 00161 00162 Specify whether or not this logger has additive behaviour. 00163 This is enabled by default, and causes a logger to invoke 00164 all appenders within its ancestry (until an ancestor is 00165 found with an additive attribute of false). 00166 00167 ***********************************************************************/ 00168 00169 void setAdditive (bool enabled); 00170 00171 /*********************************************************************** 00172 00173 Get number of milliseconds since this application started 00174 00175 ***********************************************************************/ 00176 00177 ulong getUptime (); 00178 }