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 4. Derivative works are permitted, but they must carry this notice 00027 in full and credit the original source. 00028 00029 00030 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00031 00032 00033 @version Initial version, May 2004 00034 @author Kris 00035 00036 00037 *******************************************************************************/ 00038 00039 module mango.log.model.ILogger; 00040 00041 public import mango.log.model.ILevel; 00042 00043 /******************************************************************************* 00044 00045 This is the primary API to the log package. Use the two static 00046 methods to access and/or create Logger instances, and the other 00047 methods to modify specific Logger attributes. 00048 00049 See <A HREF="http://logging.apache.org/log4j/docs/documentation.html">this page</A> 00050 for the official Log4J documentation. Mango.log closely follows 00051 both the API and the behaviour as documented at the official site. 00052 00053 *******************************************************************************/ 00054 00055 interface ILogger : ILevel 00056 { 00057 /*********************************************************************** 00058 00059 Add a trace messages. This is called 'debug' in Log4J but 00060 that is a reserved word in the D language. This needs some 00061 more thought. 00062 00063 ***********************************************************************/ 00064 00065 void trace (char[] msg); 00066 00067 /*********************************************************************** 00068 00069 Add an info message 00070 00071 ***********************************************************************/ 00072 00073 void info (char[] msg); 00074 00075 /*********************************************************************** 00076 00077 Add a warning message 00078 00079 ***********************************************************************/ 00080 00081 void warn (char[] msg); 00082 00083 /*********************************************************************** 00084 00085 Add an error message 00086 00087 ***********************************************************************/ 00088 00089 void error (char[] msg); 00090 00091 /*********************************************************************** 00092 00093 Add a fatal message 00094 00095 ***********************************************************************/ 00096 00097 void fatal (char[] msg); 00098 00099 /*********************************************************************** 00100 00101 Return the name of this Logger 00102 00103 ***********************************************************************/ 00104 00105 char[] getName (); 00106 00107 /*********************************************************************** 00108 00109 Return the current level assigned to this logger 00110 00111 ***********************************************************************/ 00112 00113 Level getLevel (); 00114 00115 /*********************************************************************** 00116 00117 Set the activity level of this logger. Levels control how 00118 much information is emitted during runtime, and relate to 00119 each other as follows: 00120 00121 Trace < Info < Warn < Error < Fatal < None 00122 00123 That is, if the level is set to Error, only calls to the 00124 error() and fatal() methods will actually produce output: 00125 all others will be inhibited. 00126 00127 Note that Log4J is a hierarchical environment, and each 00128 logger defaults to inheriting a level from its parent. 00129 00130 00131 ***********************************************************************/ 00132 00133 void setLevel (Level level); 00134 00135 /*********************************************************************** 00136 00137 same as setLevel (Level), but with additional control over 00138 whether the children are forced to accept the changed level 00139 or not. If 'force' is false, then children adopt the parent 00140 level only if they have their own level set to Level.None 00141 00142 ***********************************************************************/ 00143 00144 void setLevel (Level level, bool force); 00145 00146 /*********************************************************************** 00147 00148 Is this logger enabled for the provided level? 00149 00150 ***********************************************************************/ 00151 00152 bool isEnabled (Level level); 00153 00154 /*********************************************************************** 00155 00156 Return whether this logger uses additive appenders or not. 00157 See setAdditive(). 00158 00159 ***********************************************************************/ 00160 00161 bool isAdditive (); 00162 00163 /*********************************************************************** 00164 00165 Specify whether or not this logger has additive behaviour. 00166 This is enabled by default, and causes a logger to invoke 00167 all appenders within its ancestry (until an ancestor is 00168 found with an additive attribute of false). 00169 00170 ***********************************************************************/ 00171 00172 void setAdditive (bool enabled); 00173 00174 /*********************************************************************** 00175 00176 Get number of milliseconds since this application started 00177 00178 ***********************************************************************/ 00179 00180 ulong getUptime (); 00181 }