Changeset 2363
- Timestamp:
- 07/04/09 02:06:52 (4 years ago)
- Location:
- coldbox/trunk
- Files:
-
- 3 added
- 16 modified
-
system/logging/AbstractAppender.cfc (modified) (2 diffs)
-
system/logging/LogBox.cfc (modified) (10 diffs)
-
system/logging/LogEvent.cfc (modified) (1 diff)
-
system/logging/Logger.cfc (modified) (7 diffs)
-
system/logging/appenders/CFAppender.cfc (modified) (4 diffs)
-
system/logging/appenders/ConsoleAppender.cfc (modified) (2 diffs)
-
system/logging/appenders/DBAppender.cfc (modified) (11 diffs)
-
system/logging/appenders/EmailAppender.cfc (added)
-
system/logging/appenders/FileAppender.cfc (modified) (1 diff)
-
system/logging/appenders/ScopeAppender.cfc (modified) (5 diffs)
-
system/logging/config/LogBoxConfig.cfc (modified) (3 diffs)
-
testing/cases/logging/LogBoxTest.cfc (modified) (1 diff)
-
testing/cases/logging/LogBoxVariousTest.cfc (added)
-
testing/cases/logging/appenders/CFAppenderTest.cfc (modified) (1 diff)
-
testing/cases/logging/appenders/ConsoleAppenderTest.cfc (modified) (1 diff)
-
testing/cases/logging/appenders/DBAppenderTest.cfc (modified) (7 diffs)
-
testing/cases/logging/appenders/EmailAppenderTest.cfc (added)
-
testing/cases/logging/appenders/ScopeAppenderTest.cfc (modified) (1 diff)
-
testing/cases/logging/config/LogBoxConfigTest.cfc (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
coldbox/trunk/system/logging/AbstractAppender.cfc
r2362 r2363 58 58 <!------------------------------------------- INTERNAL OBSERVERS ------------------------------------------> 59 59 60 61 60 <cffunction name="onRegistration" access="public" hint="Runs after the appender has been created and registered. Implemented by Concrete appender" output="false" returntype="void"> 62 61 </cffunction> … … 66 65 67 66 <!------------------------------------------- PUBLIC -------------------------------------------> 67 68 <!--- severityToString ---> 69 <cffunction name="severityToString" output="false" access="public" returntype="string" hint="convert a severity to a string"> 70 <cfargument name="severity" type="numeric" required="true" hint="The severity to convert"/> 71 <cfreturn this.logLevels.lookup(arguments.severity)> 72 </cffunction> 68 73 69 74 <!--- getHash ---> -
coldbox/trunk/system/logging/LogBox.cfc
r2362 r2363 27 27 // LogBox Unique ID */ 28 28 instance._hash = hash(createUUID()); 29 // LoggersList 30 instance.appenderRegistry = ""; 29 // Appenders 30 instance.appenderRegistry = ""; 31 // Category Appenders 32 instance.categoryAppenders = ""; 31 33 // Version 32 instance.version = "1.0"; 34 instance.version = "1.0"; 35 // Configuration object 36 instance.config = ""; 33 37 </cfscript> 34 38 35 39 <!--- Init ---> 36 40 <cffunction name="init" access="public" returntype="LogBox" hint="Constructor" output="false" > 37 <cfargument name="logBoxConfig" type="coldbox.system.logging.config.LogBoxConfig" required=" false" hint="If passed, this LogBox instance will be configured with this configuration object."/>41 <cfargument name="logBoxConfig" type="coldbox.system.logging.config.LogBoxConfig" required="true" hint="The LogBoxConfig object to use to configure this instance of LogBox"/> 38 42 <cfscript> 39 43 var Collections = createObject("java", "java.util.Collections"); 40 44 41 // Prepare Logger Object Registry45 // Prepare Appender Object Registries 42 46 instance.appenderRegistry = Collections.synchronizedMap(CreateObject("java","java.util.LinkedHashMap").init(3)); 43 44 // Check if using configuration object 45 if( structKeyExists(arguments,"logBoxConfig") ){ 46 registerConfig(arguments.logBoxConfig); 47 } 48 49 /* Return Factory */ 47 instance.categoryAppenders = structnew(); 48 49 // Store config object 50 instance.config = arguments.logBoxConfig; 51 52 // Configure LogBox 53 configure(); 54 55 // Return LogBox 50 56 return this; 51 57 </cfscript> … … 56 62 <cfreturn instance.Version> 57 63 </cffunction> 64 65 <!--- Get the config object ---> 66 <cffunction name="getConfig" access="public" returntype="coldbox.system.logging.config.LogBoxConfig" output="false" hint="Get this LogBox's configuration object."> 67 <cfreturn instance.config> 68 </cffunction> 58 69 59 70 <!------------------------------------------- PUBLIC -------------------------------------------> 60 61 <!--- getHash --->62 <cffunction name="getHash" output="false" access="public" returntype="string" hint="Get this Log Box's unique ID">63 <cfreturn instance._hash>64 </cffunction>65 71 66 72 <!--- clearAppenders ---> … … 74 80 </cffunction> 75 81 82 <!--- Get the appender Registry ---> 83 <cffunction name="getAppenders" access="public" returntype="struct" output="false" hint="Get the map of registered appenders."> 84 <cfreturn instance.appenderRegistry> 85 </cffunction> 86 87 <!--- Get the category Appenders Registry ---> 88 <cffunction name="getCategoryAppenders" access="public" returntype="struct" output="false" hint="Get the map of registered category appenders."> 89 <cfreturn instance.categoryAppenders> 90 </cffunction> 91 92 <!--- getAppender ---> 93 <cffunction name="getAppender" output="false" access="public" returntype="any" hint="Get a named appender"> 94 <cfargument name="name" type="string" required="true" hint="The appender's name"/> 95 <cfscript> 96 if( appenderExists(arguments.name) ){ 97 return structFind(getAppenders(),arguments.name); 98 } 99 else{ 100 getutil().throwit(message="Appender #arguments.name# does not exist.",type="LogBox.AppenderNotFound"); 101 } 102 </cfscript> 103 </cffunction> 104 76 105 <!--- appenderExists ---> 77 106 <cffunction name="appenderExists" output="false" access="public" returntype="boolean" hint="Checks to see if a specified appender exists by name."> 78 107 <cfargument name="name" type="string" required="true" hint="The name of the appender to check if it is registered"/> 79 108 <cfreturn structKeyExists(getAppenders(), arguments.name)> 80 </cffunction>81 82 <!--- register --->83 <cffunction name="registerConfig" output="false" access="public" returntype="void" hint="Registers all the appenders in a LogBoxConfig object">84 <!--- ************************************************************* --->85 <cfargument name="logBoxConfig" type="coldbox.system.logging.config.LogBoxConfig" required="true"/>86 <!--- ************************************************************* --->87 <cfscript>88 var appendersArray = arguments.logBoxConfig.getAppenders();89 var x =1;90 91 for(x=1; x lte arrayLen(appendersArray); x=x+1){92 // Register configurations.93 registerNew(argumentCollection=appendersArray[x]);94 }95 </cfscript>96 109 </cffunction> 97 110 … … 111 124 <!--- Verify Registration ---> 112 125 <cfif NOT appenderExists(name)> 113 <cflock name="# getHash()#.#name#" type="exclusive" throwontimeout="true" timeout="30">126 <cflock name="#instance._hash#.#name#" type="exclusive" throwontimeout="true" timeout="30"> 114 127 <cfscript> 115 128 if( NOT appenderExists(name) ){ … … 124 137 </cflock> 125 138 <cfelse> 126 <cflog type="warning" file="LogBox" text="LogBoxID: # getHash()# - Cannot register appender #name# as it is already registered. Skipping.">139 <cflog type="warning" file="LogBox" text="LogBoxID: #instance._hash# - Cannot register appender #name# as it is already registered. Skipping."> 127 140 </cfif> 128 141 </cffunction> … … 176 189 <cfscript> 177 190 var logger = createObject("component","coldbox.system.logging.Logger"); 191 var args = structnew(); 192 var config = getConfig(); 193 var appenders = getCategoryAppenders(); 194 var categoryConfig = ""; 195 196 // Set category name in config 197 args.category = arguments.category; 198 199 // Verify if category exists to get appenders and data info. 200 if( config.categoryExists(arguments.category) ){ 201 categoryConfig = config.getCategory(arguments.category); 202 args.levelMin = categoryConfig.levelMin; 203 args.levelMax = categoryConfig.levelMax; 204 // Get Appenders from storage map 205 args.appenders = appenders[arguments.category]; 206 } 178 207 179 208 // Dependencies … … 182 211 183 212 // Init it 184 return logger.init(argument s.category);213 return logger.init(argumentCollection=args); 185 214 </cfscript> 186 215 </cffunction> … … 256 285 <!------------------------------------------- PRIVATE ------------------------------------------> 257 286 258 <!--- Get the appender Registry ---> 259 <cffunction name="getAppenders" access="private" returntype="struct" output="false" hint="Get the map of registered loggers."> 260 <cfreturn instance.appenderRegistry> 287 <!--- configure ---> 288 <cffunction name="configure" output="false" access="private" returntype="void" hint="Configure logbox for operation"> 289 <cfscript> 290 var config = getConfig(); 291 var appenders = config.getAppenders(); 292 var key = ""; 293 var categories = config.getCategories(); 294 295 // Register All Appenders configured 296 for( key in appenders ){ 297 registerNew(argumentCollection=appenders[key]); 298 } 299 // Clean just in case 300 key = ""; 301 // Register All Category Appenders defined in the configuration object. 302 for( key in categories ){ 303 instance.categoryAppenders[key] = getAppendersMap(categories[key].appenders); 304 } 305 </cfscript> 306 </cffunction> 307 308 <!--- getAppendersMap ---> 309 <cffunction name="getAppendersMap" output="false" access="private" returntype="struct" hint="Get a map of appenders by list"> 310 <cfargument name="appenders" type="string" required="true" hint="The list of appenders to get"/> 311 <cfscript> 312 var x =1; 313 var appenders = getAppenders(); 314 var Collections = createObject("java", "java.util.Collections"); 315 var map = Collections.synchronizedMap(CreateObject("java","java.util.LinkedHashMap").init(listlen(arguments.appenders))); 316 317 for(x=1; x lte listlen(arguments.appenders); x=x+1){ 318 thisAppender = listGetAt(arguments.appenders,x); 319 map[thisAppender] = appenders[thisAppender]; 320 } 321 322 return map; 323 </cfscript> 261 324 </cffunction> 262 325 … … 274 337 var key = ""; 275 338 var thisAppender = ""; 339 var logEvent = ""; 340 341 // Do we have appenders? 342 if( NOT hasAppenders() ){ return; } 276 343 277 344 // If message empty, just exit … … 284 351 // Delegate Calls 285 352 for(key in appenders){ 286 // Get logger353 // Get Appender 287 354 thisAppender = appenders[key]; 288 355 // Log Check 289 356 if( thisAppender.canLog(arguments.severity) ){ 290 357 // Log the message in the appender 291 358 thisAppender.logMessage(logEvent); 292 359 } -
coldbox/trunk/system/logging/LogEvent.cfc
r2362 r2363 32 32 instance[key] = arguments[key]; 33 33 } 34 return this; 34 35 </cfscript> 35 36 </cffunction> -
coldbox/trunk/system/logging/Logger.cfc
r2362 r2363 20 20 21 21 // private instance scope 22 instance = structnew(); 22 instance = structnew(); 23 instance.category = ""; 24 instance.levelMin = ""; 25 instance.levelMax = ""; 26 instance.appenders = ""; 23 27 </cfscript> 24 28 25 29 <!--- Init ---> 26 30 <cffunction name="init" access="public" returntype="Logger" hint="Constructor" output="false" > 27 <cfargument name="category" type="string" required="true" hint="The category name to use this logger with"/> 28 <cfscript> 29 // Setup the category 31 <cfargument name="category" type="string" required="true" hint="The category name to use this logger with"/> 32 <cfargument name="levelMin" type="numeric" required="false" default="0" hint="The default log level for this appender, by default it is 0. Optional. ex: LogBox.logLevels.WARNING"/> 33 <cfargument name="levelMax" type="numeric" required="false" default="5" hint="The default log level for this appender, by default it is 5. Optional. ex: LogBox.logLevels.WARNING"/> 34 <cfargument name="appenders" type="struct" required="false" default="#structnew()#" hint="A map of appenders for this category"/> 35 <cfscript> 30 36 instance.category = arguments.category; 31 37 instance.levelMin = arguments.levelMin; 38 instance.levelMax = arguments.levelMax; 39 instance.appenders = arguments.appenders; 32 40 return this; 33 41 </cfscript> 34 42 </cffunction> 43 44 <!--- hasAppenders ---> 45 <cffunction name="hasAppenders" output="false" access="public" returntype="boolean" hint="Checks to see if we have registered any appenders yet"> 46 <cfreturn NOT getAppenders().isEmpty()> 47 </cffunction> 35 48 36 49 <!------------------------------------------- FACADE Methods -------------------------------------------> 50 51 <!--- Get the Appenders ---> 52 <cffunction name="getappenders" access="public" returntype="struct" output="false" hint="Get the appenders for this logger"> 53 <cfreturn instance.appenders> 54 </cffunction> 55 56 <!--- Level Min ---> 57 <cffunction name="getlevelMin" access="public" returntype="numeric" output="false" hint="Get the level min setting"> 58 <cfreturn instance.levelMin> 59 </cffunction> 60 <cffunction name="setLevelMin" access="public" output="false" returntype="void" hint="Set the appender's default levelMin"> 61 <cfargument name="levelMin" type="numeric" required="true"/> 62 <cfscript> 63 // Verify level 64 if( this.logLevels.isLevelValid(arguments.levelMin) AND 65 arguments.levelMin lte getLevelMax() ){ 66 instance.levelMin = arguments.levelMin; 67 } 68 else{ 69 $throw("Invalid Log Level","The log level #arguments.levelMin# is invalid or greater than the levelMax (#getLevelMax()#). Valid log levels are from 0 to 5","Logger.InvalidLogLevelException"); 70 } 71 </cfscript> 72 </cffunction> 73 74 <!--- GetSet level Max ---> 75 <cffunction name="getlevelMax" access="public" returntype="numeric" output="false" hint="Get the level Max setting"> 76 <cfreturn instance.levelMax> 77 </cffunction> 78 <cffunction name="setLevelMax" access="public" output="false" returntype="void" hint="Set the appender's default levelMax"> 79 <cfargument name="levelMax" type="numeric" required="true"/> 80 <cfscript> 81 // Verify level 82 if( this.logLevels.isLevelValid(arguments.levelMax) AND 83 arguments.levelMax gte getLevelMin() ){ 84 instance.levelMax = arguments.levelMax; 85 } 86 else{ 87 $throw("Invalid Log Level","The log level #arguments.levelMax# is invalid or less than the levelMin (#getLevelMin()#). Valid log levels are from 0 to 5","Logger.InvalidLogLevelException"); 88 } 89 </cfscript> 90 </cffunction> 37 91 38 92 <!--- get/set category object. ---> … … 52 106 <cfargument name="category" type="string" required="false" default="" hint="The category to log this message under. By default it is blank."/> 53 107 <!--- ************************************************************* ---> 54 <cfset arguments.category = getCategory()> 55 <cfset this.logBox.debug(argumentCollection=arguments)> 108 <cfscript> 109 arguments.category = getCategory(); 110 if( hasAppenders() ){ 111 arguments.severity = this.logLevels.DEBUG; 112 logMessage(argumentCollection=arguments); 113 } 114 else{ 115 this.logBox.debug(argumentCollection=arguments); 116 } 117 </cfscript> 56 118 </cffunction> 57 119 … … 63 125 <cfargument name="category" type="string" required="false" default="" hint="The category to log this message under. By default it is blank."/> 64 126 <!--- ************************************************************* ---> 65 <cfset arguments.category = getCategory()> 66 <cfset this.logBox.info(argumentCollection=arguments)> 127 <cfscript> 128 arguments.category = getCategory(); 129 if( hasAppenders() ){ 130 arguments.severity = this.logLevels.INFO; 131 logMessage(argumentCollection=arguments); 132 } 133 else{ 134 this.logBox.info(argumentCollection=arguments); 135 } 136 </cfscript> 67 137 </cffunction> 68 138 … … 74 144 <cfargument name="category" type="string" required="false" default="" hint="The category to log this message under. By default it is blank."/> 75 145 <!--- ************************************************************* ---> 76 <cfset arguments.category = getCategory()> 77 <cfset this.logBox.trace(argumentCollection=arguments)> 146 <cfscript> 147 arguments.category = getCategory(); 148 if( hasAppenders() ){ 149 arguments.severity = this.logLevels.TRACE; 150 logMessage(argumentCollection=arguments); 151 } 152 else{ 153 this.logBox.trace(argumentCollection=arguments); 154 } 155 </cfscript> 78 156 </cffunction> 79 157 … … 85 163 <cfargument name="category" type="string" required="false" default="" hint="The category to log this message under. By default it is blank."/> 86 164 <!--- ************************************************************* ---> 87 <cfset arguments.category = getCategory()> 88 <cfset this.logBox.warn(argumentCollection=arguments)> 165 <cfscript> 166 arguments.category = getCategory(); 167 if( hasAppenders() ){ 168 arguments.severity = this.logLevels.WARN; 169 logMessage(argumentCollection=arguments); 170 } 171 else{ 172 this.logBox.warn(argumentCollection=arguments); 173 } 174 </cfscript> 89 175 </cffunction> 90 176 … … 96 182 <cfargument name="category" type="string" required="false" default="" hint="The category to log this message under. By default it is blank."/> 97 183 <!--- ************************************************************* ---> 98 <cfset arguments.category = getCategory()> 99 <cfset this.logBox.error(argumentCollection=arguments)> 184 <cfscript> 185 arguments.category = getCategory(); 186 if( hasAppenders() ){ 187 arguments.severity = this.logLevels.ERROR; 188 logMessage(argumentCollection=arguments); 189 } 190 else{ 191 this.logBox.error(argumentCollection=arguments); 192 } 193 </cfscript> 100 194 </cffunction> 101 195 … … 107 201 <cfargument name="category" type="string" required="false" default="" hint="The category to log this message under. By default it is blank."/> 108 202 <!--- ************************************************************* ---> 109 <cfset arguments.category = getCategory()> 110 <cfset this.logBox.fatal(argumentCollection=arguments)> 111 </cffunction> 112 203 <cfscript> 204 arguments.category = getCategory(); 205 if( hasAppenders() ){ 206 arguments.severity = this.logLevels.fatal; 207 logMessage(argumentCollection=arguments); 208 } 209 else{ 210 this.logBox.fatal(argumentCollection=arguments); 211 } 212 </cfscript> 213 </cffunction> 214 215 <!--- canLog ---> 216 <cffunction name="canLog" output="false" access="public" returntype="boolean" hint="Checks wether a log can be made on this appender using a passed in level"> 217 <cfargument name="level" type="numeric" required="true" default="" hint="The level to check"/> 218 <cfscript> 219 return (arguments.level GTE getLevelMin() AND arguments.level LTE getLevelMax() ); 220 </cfscript> 221 </cffunction> 222 113 223 <!------------------------------------------- PRIVATE ------------------------------------------> 114 224 115 225 <!--- logMessage ---> 226 <cffunction name="logMessage" output="false" access="private" returntype="void" hint="Write an entry into the loggers registered with this LogBox instance."> 227 <!--- ************************************************************* ---> 228 <cfargument name="message" type="string" required="true" hint="The message to log."> 229 <cfargument name="severity" type="numeric" required="true" hint="The severity level to log."> 230 <cfargument name="extraInfo" type="any" required="false" default="" hint="Extra information to send to the loggers."> 231 <cfargument name="category" type="string" required="false" default="" hint="The category to log this message under. By default it is blank."/> 232 <!--- ************************************************************* ---> 233 <cfscript> 234 // Loop over loggers 235 var appenders = getAppenders(); 236 var key = ""; 237 var thisAppender = ""; 238 var logEvent = ""; 239 240 // If message empty, just exit 241 arguments.message = trim(arguments.message); 242 if( NOT len(arguments.message) ){ return; } 243 244 // Check if category can log? 245 if( canLog(arguments.severity) ){ 246 // Create Logging Event 247 logEvent = createobject("component","coldbox.system.logging.LogEvent").init(argumentCollection=arguments); 248 249 // Delegate Calls 250 for(key in appenders){ 251 // Get Appender 252 thisAppender = appenders[key]; 253 // Log the message in the appender 254 thisAppender.logMessage(logEvent); 255 } 256 } 257 </cfscript> 258 </cffunction> 259 260 <!--- Throw Facade ---> 261 <cffunction name="$throw" access="private" hint="Facade for cfthrow" output="false"> 262 <!--- ************************************************************* ---> 263 <cfargument name="message" type="string" required="yes"> 264 <cfargument name="detail" type="string" required="no" default=""> 265 <cfargument name="type" type="string" required="no" default="Framework"> 266 <!--- ************************************************************* ---> 267 <cfthrow type="#arguments.type#" message="#arguments.message#" detail="#arguments.detail#"> 268 </cffunction> 116 269 </cfcomponent> -
coldbox/trunk/system/logging/appenders/CFAppender.cfc
r2362 r2363 8 8 Date : 04/12/2009 9 9 Description : 10 A simple CF Logger10 A simple CF appender 11 11 12 12 Properties: … … 14 14 - logType : file or application 15 15 -----------------------------------------------------------------------> 16 <cfcomponent name="CF Logger"16 <cfcomponent name="CFAppender" 17 17 extends="coldbox.system.logging.AbstractAppender" 18 18 output="false" 19 hint="A simple CF Logger">19 hint="A simple CF Appender"> 20 20 21 21 <!--- Init ---> 22 <cffunction name="init" access="public" returntype="CF Logger" hint="Constructor called by a Concrete Logger" output="false" >22 <cffunction name="init" access="public" returntype="CFAppender" hint="Constructor" output="false" > 23 23 <!--- ************************************************************* ---> 24 <cfargument name="name" type="string" required="true" hint="The unique name for this logger."/>25 <cfargument name="levelMin" type="numeric" required="false" default="0" hint="The default log level for this logger, by default it is 0. Optional. ex: LogBox.logLevels.WARNING"/>26 <cfargument name="levelMax" type="numeric" required="false" default="5" hint="The default log level for this logger, by default it is 5. Optional. ex: LogBox.logLevels.WARNING"/>27 <cfargument name="properties" type="struct" required="false" default="#structnew()#" hint="A map of configuration properties for the logger"/>24 <cfargument name="name" type="string" required="true" hint="The unique name for this appender."/> 25 <cfargument name="levelMin" type="numeric" required="false" default="0" hint="The default log level for this appender, by default it is 0. Optional. ex: LogBox.logLevels.WARNING"/> 26 <cfargument name="levelMax" type="numeric" required="false" default="5" hint="The default log level for this appender, by default it is 5. Optional. ex: LogBox.logLevels.WARNING"/> 27 <cfargument name="properties" type="struct" required="false" default="#structnew()#" hint="A map of configuration properties for the appender"/> 28 28 <!--- ************************************************************* ---> 29 29 <cfscript> … … 40 40 $throw(message="Invalid logtype choosen #getProperty("logType")#", 41 41 detail="Valid types are file or application", 42 type="CF Logger.InvalidLogTypeException");42 type="CFAppender.InvalidLogTypeException"); 43 43 } 44 44 } … … 49 49 50 50 <!--- Log Message ---> 51 <cffunction name="logMessage" access="public" output="false" returntype="void" hint="Write an entry into the logger.">51 <cffunction name="logMessage" access="public" output="false" returntype="void" hint="Write an entry into the appender."> 52 52 <!--- ************************************************************* ---> 53 <cfargument name="message" type="string" required="true" hint="The message to log."> 54 <cfargument name="severity" type="numeric" required="true" hint="The severity level to log."> 55 <cfargument name="extraInfo" type="any" required="no" default="" hint="Extra information to send to the loggers."> 53 <cfargument name="logEvent" type="coldbox.system.logging.LogEvent" required="true" hint="The logging event"/> 56 54 <!--- ************************************************************* ---> 55 <cfset var loge = arguments.logEvent> 57 56 58 57 <cfif getProperty("logType") eq "file"> 59 58 <cflog file="#getName()#" 60 type="# this.logLevels.lookup(arguments.severity)#"61 text="# arguments.message#">59 type="#severityToString(loge.getSeverity())#" 60 text="#loge.getCategory()# #loge.getMessage()#"> 62 61 <cfelse> 63 62 <cflog log="Application" 64 type="# this.logLevels.lookup(arguments.severity)#"65 text="# arguments.message#">63 type="#severityToString(loge.getSeverity())#" 64 text="#loge.getCategory()# #loge.getMessage()#"> 66 65 </cfif> 67 66 -
coldbox/trunk/system/logging/appenders/ConsoleAppender.cfc
r2362 r2363 8 8 Date : 04/12/2009 9 9 Description : 10 A simple Console Logger10 A simple ConsoleAppender 11 11 12 12 Properties: 13 13 - none 14 14 -----------------------------------------------------------------------> 15 <cfcomponent name="Console Logger"15 <cfcomponent name="ConsoleAppender" 16 16 extends="coldbox.system.logging.AbstractAppender" 17 17 output="false" 18 hint="A simple Console Logger">18 hint="A simple Console Appender"> 19 19 20 20 <!--- Init ---> 21 <cffunction name="init" access="public" returntype="C FLogger" hint="Constructor called by a Concrete Logger" output="false" >21 <cffunction name="init" access="public" returntype="ConsoleAppender" hint="Constructor" output="false" > 22 22 <!--- ************************************************************* ---> 23 <cfargument name="name" type="string" required="true" hint="The unique name for this logger."/>24 <cfargument name="levelMin" type="numeric" required="false" default="0" hint="The default log level for this logger, by default it is 0. Optional. ex: LogBox.logLevels.WARNING"/>25 <cfargument name="levelMax" type="numeric" required="false" default="5" hint="The default log level for this logger, by default it is 5. Optional. ex: LogBox.logLevels.WARNING"/>26 <cfargument name="properties" type="struct" required="false" default="#structnew()#" hint="A map of configuration properties for the logger"/>23 <cfargument name="name" type="string" required="true" hint="The unique name for this appender."/> 24 <cfargument name="levelMin" type="numeric" required="false" default="0" hint="The default log level for this appender, by default it is 0. Optional. ex: LogBox.logLevels.WARNING"/> 25 <cfargument name="levelMax" type="numeric" required="false" default="5" hint="The default log level for this appender, by default it is 5. Optional. ex: LogBox.logLevels.WARNING"/> 26 <cfargument name="properties" type="struct" required="false" default="#structnew()#" hint="A map of configuration properties for the appender"/> 27 27 <!--- ************************************************************* ---> 28 28 <cfscript> … … 37 37 38 38 <!--- Log Message ---> 39 <cffunction name="logMessage" access="public" output="false" returntype="void" hint="Write an entry into the logger.">39 <cffunction name="logMessage" access="public" output="false" returntype="void" hint="Write an entry into the appender."> 40 40 <!--- ************************************************************* ---> 41 <cfargument name="message" type="string" required="true" hint="The message to log."> 42 <cfargument name="severity" type="numeric" required="true" hint="The severity level to log."> 43 <cfargument name="extraInfo" type="any" required="no" default="" hint="Extra information to send to the loggers."> 41 <cfargument name="logEvent" type="coldbox.system.logging.LogEvent" required="true" hint="The logging event"/> 44 42 <!--- ************************************************************* ---> 45 43 <cfscript> 46 44 var extra = ""; 45 var loge = arguments.logEvent; 46 47 47 try{ 48 extra = arguments.extraInfo.toString();48 extra = loge.extraInfo.toString(); 49 49 } 50 50 catch(Any e){ 51 $log("ERROR","Extrainfo toString() failed on #getName()# logger. #e.message# #e.detail#");51 $log("ERROR","Extrainfo toString() failed on #getName()# appender. #e.message# #e.detail#"); 52 52 } 53 instance.out.println(" #this.logLevels.lookup(arguments.severity)# #arguments.message# #chr(13)# #extra#"); 53 54 // Log message 55 instance.out.println("#severityToString(loge.getseverity())# #loge.getCategory()# #loge.getmessage()# #chr(13)# #extra#"); 54 56 </cfscript> 55 57 </cffunction> -
coldbox/trunk/system/logging/appenders/DBAppender.cfc
r2362 r2363 8 8 Date : 04/12/2009 9 9 Description : 10 A simple DB logger for MySQL, MSSQL, Oracle, PostgreSQL10 A simple DB appender for MySQL, MSSQL, Oracle, PostgreSQL 11 11 12 12 Inspiration from Tim Blair <tim@bla.ir> cflogger project. … … 24 24 - category : string 25 25 - logdate : timestamp 26 - loggername : string26 - appendername : string 27 27 - message : string 28 28 … … 30 30 31 31 -----------------------------------------------------------------------> 32 <cfcomponent name="DB Logger"32 <cfcomponent name="DBAppender" 33 33 extends="coldbox.system.logging.AbstractAppender" 34 34 output="false" 35 hint="This is a simple implementation of a logger that is db based.">35 hint="This is a simple implementation of a appender that is db based."> 36 36 37 37 <!--- Init ---> 38 <cffunction name="init" access="public" returntype="DB Logger" hint="Constructor called by a Concrete Logger" output="false" >38 <cffunction name="init" access="public" returntype="DBAppender" hint="Constructor" output="false" > 39 39 <!--- ************************************************************* ---> 40 <cfargument name="name" type="string" required="true" hint="The unique name for this logger."/>41 <cfargument name="levelMin" type="numeric" required="false" default="0" hint="The default log level for this logger, by default it is 0. Optional. ex: LogBox.logLevels.WARNING"/>42 <cfargument name="levelMax" type="numeric" required="false" default="5" hint="The default log level for this logger, by default it is 5. Optional. ex: LogBox.logLevels.WARNING"/>43 <cfargument name="properties" type="struct" required="false" default="#structnew()#" hint="A map of configuration properties for the logger"/>40 <cfargument name="name" type="string" required="true" hint="The unique name for this appender."/> 41 <cfargument name="levelMin" type="numeric" required="false" default="0" hint="The default log level for this appender, by default it is 0. Optional. ex: LogBox.logLevels.WARNING"/> 42 <cfargument name="levelMax" type="numeric" required="false" default="5" hint="The default log level for this appender, by default it is 5. Optional. ex: LogBox.logLevels.WARNING"/> 43 <cfargument name="properties" type="struct" required="false" default="#structnew()#" hint="A map of configuration properties for the appender"/> 44 44 <!--- ************************************************************* ---> 45 45 <cfscript> … … 49 49 // Verify properties 50 50 if( NOT propertyExists('dsn') ){ 51 $throw(message="No dsn property defined",type="DB Logger.InvalidProperty");51 $throw(message="No dsn property defined",type="DBAppender.InvalidProperty"); 52 52 } 53 53 if( NOT propertyExists('table') ){ 54 $throw(message="No table property defined",type="DB Logger.InvalidProperty");54 $throw(message="No table property defined",type="DBAppender.InvalidProperty"); 55 55 } 56 56 if( NOT propertyExists('autoCreate') OR NOT isBoolean(getProperty('autoCreate')) ){ … … 65 65 66 66 // columns 67 instance.columns = "id,severity,category,logdate, loggername,message";67 instance.columns = "id,severity,category,logdate,appendername,message"; 68 68 69 69 return this; … … 82 82 83 83 <!--- Log Message ---> 84 <cffunction name="logMessage" access="public" output="false" returntype="void" hint="Write an entry into the logger.">84 <cffunction name="logMessage" access="public" output="false" returntype="void" hint="Write an entry into the appender."> 85 85 <!--- ************************************************************* ---> 86 <cfargument name="message" type="string" required="true" hint="The message to log."> 87 <cfargument name="severity" type="numeric" required="true" hint="The severity level to log."> 88 <cfargument name="extraInfo" type="any" required="no" default="" hint="Extra information to send to the loggers."> 86 <cfargument name="logEvent" type="coldbox.system.logging.LogEvent" required="true" hint="The logging event"/> 89 87 <!--- ************************************************************* ---> 90 88 <cfscript> … … 93 91 var cmap = ""; 94 92 var cols = ""; 93 var loge = arguments.logEvent; 95 94 96 95 // Check Category Sent? 97 if ( isStruct(arguments.extraInfo) and structKeyExists(arguments.extraInfo,"Category")){98 category = arguments.extraInfo.category;96 if( NOT loge.getCategory() eq "" ){ 97 category = loge.getCategory(); 99 98 } 99 100 100 // Column Maps 101 101 if( propertyExists('columnMap') ){ 102 102 cmap = getProperty('columnMap'); 103 cols = "#cmap.id#,#cmap.severity#,#cmap.category#,#cmap.logdate#,#cmap. loggername#,#cmap.message#";103 cols = "#cmap.id#,#cmap.severity#,#cmap.category#,#cmap.logdate#,#cmap.appendername#,#cmap.message#"; 104 104 } 105 105 else{ … … 112 112 INSERT INTO #getProperty('table')# (#cols#) VALUES ( 113 113 <cfqueryparam cfsqltype="cf_sql_varchar" value="#createUUID()#">, 114 <cfqueryparam cfsqltype="cf_sql_varchar" value="# this.logLevels.lookup(arguments.severity)#">,114 <cfqueryparam cfsqltype="cf_sql_varchar" value="#severityToString(loge.getseverity())#">, 115 115 <cfqueryparam cfsqltype="cf_sql_varchar" value="#category#">, 116 <cfqueryparam cfsqltype="cf_sql_timestamp" value="# now()#">,116 <cfqueryparam cfsqltype="cf_sql_timestamp" value="#loge.getTimestamp()#">, 117 117 <cfqueryparam cfsqltype="cf_sql_varchar" value="#left(getName(),100)#">, 118 <cfqueryparam cfsqltype="cf_sql_varchar" value="# arguments.message#">118 <cfqueryparam cfsqltype="cf_sql_varchar" value="#loge.getmessage()#"> 119 119 ) 120 120 </cfquery> … … 129 129 130 130 if( NOT structKeyExists(datasources, getProperty('dsn')) ){ 131 $throw(message="The dsn #getProperty("dsn")# does not exist. Please create it before using this DB Logger",type="DBLogger.DSNException");131 $throw(message="The dsn #getProperty("dsn")# does not exist. Please create it before using this DBAppender",type="DBAppender.DSNException"); 132 132 } 133 133 </cfscript> … … 170 170 <!--- Throw Error ---> 171 171 <cfthrow message="Table #getProperty('table')# was not found in the defined datasource: #dsn#. Please create the appropriate logging table." 172 detail="The autocreate property for this logger is set to false."173 type="DB Logger.TableNotFoundException">172 detail="The autocreate property for this appender is set to false." 173 type="DBAppender.TableNotFoundException"> 174 174 </cfif> 175 175 </cffunction> … … 182 182 for(key in map){ 183 183 if( NOT listFindNoCase(instance.columns,key) ){ 184 $throw(message="Invalid column map key: #key#",detail="The available keys are #instance.columns#",type="DB Logger.InvalidColumnMapException");184 $throw(message="Invalid column map key: #key#",detail="The available keys are #instance.columns#",type="DBAppender.InvalidColumnMapException"); 185 185 } 186 186 } -
coldbox/trunk/system/logging/appenders/FileAppender.cfc
r2362 r2363 20 20 <cffunction name="init" access="public" returntype="SimpleLogger" hint="Constructor" output="false"> 21 21 <!--- ************************************************************* ---> 22 <cfargument name="name" type="string" required="true" hint="The unique name for this logger."/> 23 <cfargument name="levelMin" type="numeric" required="false" default="0" hint="The default log level for this logger, by default it is 0. Optional. ex: LogBox.logLevels.WARNING"/> 24 <cfargument name="levelMax" type="numeric" required="false" default="5" hint="The default log level for this logger, by default it is 5. Optional. ex: LogBox.logLevels.WARNING"/> 25 <cfargument name="properties" type="struct" required="false" default="#structnew()#" hint="A map of configuration properties for the logger"/> 22 <cfargument name="logEvent" type="coldbox.system.logging.LogEvent" required="true" hint="The logging event"/> 26 23 <!--- ************************************************************* ---> 27 24 <cfscript> -
coldbox/trunk/system/logging/appenders/ScopeAppender.cfc
r2362 r2363 8 8 Date : 04/12/2009 9 9 Description : 10 A simple Scope Logger that logs to a specified scope.10 A simple Scope Appender that logs to a specified scope. 11 11 12 12 Inspiration from Tim Blair <tim@bla.ir> by the cflogger project … … 14 14 Properties: 15 15 - scope : the scope to persist to, defaults to request (optional) 16 - key : the key to use in the scope, it defaults to the name of the logger (optional)16 - key : the key to use in the scope, it defaults to the name of the Appender (optional) 17 17 - limit : a limit to the amount of logs to rotate. Defaults to 0, unlimited (optional) 18 18 19 19 -----------------------------------------------------------------------> 20 <cfcomponent name="Scope Logger"20 <cfcomponent name="ScopeAppender" 21 21 extends="coldbox.system.logging.AbstractAppender" 22 22 output="false" 23 hint="A s imple CF Logger">23 hint="A scope appender"> 24 24 25 25 <!--- Init ---> 26 <cffunction name="init" access="public" returntype="Scope Logger" hint="Constructor" output="false" >26 <cffunction name="init" access="public" returntype="ScopeAppender" hint="Constructor" output="false" > 27 27 <!--- ************************************************************* ---> 28 <cfargument name="name" type="string" required="true" hint="The unique name for this logger."/>29 <cfargument name="levelMin" type="numeric" required="false" default="0" hint="The default log level for this logger, by default it is 0. Optional. ex: LogBox.logLevels.WARNING"/>30 <cfargument name="levelMax" type="numeric" required="false" default="5" hint="The default log level for this logger, by default it is 5. Optional. ex: LogBox.logLevels.WARNING"/>31 <cfargument name="properties" type="struct" required="false" default="#structnew()#" hint="A map of configuration properties for the logger"/>28 <cfargument name="name" type="string" required="true" hint="The unique name for this appender."/> 29 <cfargument name="levelMin" type="numeric" required="false" default="0" hint="The default log level for this appender, by default it is 0. Optional. ex: LogBox.logLevels.WARNING"/> 30 <cfargument name="levelMax" type="numeric" required="false" default="5" hint="The default log level for this appender, by default it is 5. Optional. ex: LogBox.logLevels.WARNING"/> 31 <cfargument name="properties" type="struct" required="false" default="#structnew()#" hint="A map of configuration properties for the appender"/> 32 32 <!--- ************************************************************* ---> 33 33 <cfscript> … … 56 56 57 57 <!--- Log Message ---> 58 <cffunction name="logMessage" access="public" output="true" returntype="void" hint="Write an entry into the logger.">58 <cffunction name="logMessage" access="public" output="true" returntype="void" hint="Write an entry into the appender."> 59 59 <!--- ************************************************************* ---> 60 <cfargument name="message" type="string" required="true" hint="The message to log."> 61 <cfargument name="severity" type="numeric" required="true" hint="The severity level to log."> 62 <cfargument name="extraInfo" type="any" required="no" default="" hint="Extra information to send to the loggers."> 60 <cfargument name="logEvent" type="coldbox.system.logging.LogEvent" required="true" hint="The logging event"/> 63 61 <!--- ************************************************************* ---> 64 62 <cfscript> … … 66 64 var entry = structnew(); 67 65 var limit = getProperty('limit'); 66 var loge = arguments.logEvent; 68 67 69 68 // Verify storage … … 80 79 // Log Away 81 80 entry.id = createUUID(); 82 entry.logDate = now(); 83 entry.loggerName = getName(); 84 entry.severity = this.logLevels.lookup(arguments.severity); 85 entry.message = arguments.message; 86 entry.extraInfo = arguments.extraInfo.toString(); 81 entry.logDate = loge.getTimeStamp(); 82 entry.appenderName = getName(); 83 entry.severity = severityToString(loge.getseverity()); 84 entry.message = loge.getMessage(); 85 entry.extraInfo = loge.getextraInfo().toString(); 86 entry.category = loge.getCategory(); 87 87 88 88 // Save Storage -
coldbox/trunk/system/logging/config/LogBoxConfig.cfc
r2362 r2363 19 19 // Instance private scope 20 20 instance = structnew(); 21 instance.appenders = arraynew(1); 21 instance.appenders = createObject("java", "java.util.Collections").synchronizedMap(CreateObject("java","java.util.LinkedHashMap").init(3)); 22 instance.categories = structnew(); 22 23 </cfscript> 23 24 … … 27 28 </cffunction> 28 29 29 <!--- add Logger --->30 <cffunction name="add " output="false" access="public" returntype="void" hint="Add an appender configuration">30 <!--- addAppender ---> 31 <cffunction name="addAppender" output="false" access="public" returntype="void" hint="Add an appender configuration"> 31 32 <cfargument name="name" type="string" required="true" hint="A unique name for the appender to register. Only unique names can be registered per instance."/> 32 33 <cfargument name="class" type="string" required="true" hint="The appender's class to register. We will create, init it and register it for you."/> … … 34 35 <cfargument name="levelMax" type="numeric" required="false" default="5" hint="The default log level for this appender, by default it is 5. Optional. ex: LogBox.logLevels.WARNING"/> 35 36 <cfargument name="properties" type="struct" required="false" default="#structnew()#" hint="The structure of properties to configure this appender with."/> 36 <cfset arrayAppend(getAppenders(),arguments)> 37 <cfset instance.appenders[arguments.name] = arguments> 38 </cffunction> 39 40 <!--- addCategory ---> 41 <cffunction name="addCategory" output="false" access="public" returntype="void" hint="Add a new category configuration with appender(s). Appenders MUST be defined first, else this method will throw an exception"> 42 <cfargument name="name" type="string" required="true" hint="A unique name for the appender to register. Only unique names can be registered per instance."/> 43 <cfargument name="levelMin" type="numeric" required="false" default="0" hint="The default log level for this appender, by default it is 0. Optional. ex: LogBox.logLevels.WARNING"/> 44 <cfargument name="levelMax" type="numeric" required="false" default="5" hint="The default log level for this appender, by default it is 5. Optional. ex: LogBox.logLevels.WARNING"/> 45 <cfargument name="appenders" type="string" required="true" hint="A list of appender names to configure this category with."/> 46 <cfscript> 47 var x = 1; 48 49 // Verify Appenders first 50 for(x=1; x lte listlen(arguments.appenders); x=x+1){ 51 if( NOT structKeyExists(instance.appenders, listGetAt(arguments.appenders,x)) ){ 52 $throw(message="Invalid appender", 53 detail="The appender #listGetAt(arguments.appenders,x)# has not been defined yet. Please define it first.", 54 type="LogBoxConfig.AppenderNotFound"); 55 } 56 } 57 // Add category registration 58 instance.categories[arguments.name] = arguments; 59 </cfscript> 60 </cffunction> 61 62 <!--- getCategory ---> 63 <cffunction name="getCategory" output="false" access="public" returntype="struct" hint="Get a specifed category definition"> 64 <cfargument name="name" type="string" required="true" hint="The category to retrieve"/> 65 <cfreturn instance.categories[arguments.name]> 66 </cffunction> 67 68 <!--- categoryExists ---> 69 <cffunction name="categoryExists" output="false" access="public" returntype="boolean" hint="Check if a category definition exists"> 70 <cfargument name="name" type="string" required="true" hint="The category to retrieve"/> 71 <cfreturn structKeyExists(instance.categories, arguments.name)> 72 </cffunction> 73 74 <!--- getCategories ---> 75 <cffunction name="getCategories" output="false" access="public" returntype="struct" hint="Get the configured categories"> 76 <cfreturn instance.categories> 37 77 </cffunction> 38 78 39 79 <!--- getappenders ---> 40 <cffunction name="getAppenders" output="false" access="public" returntype=" array" hint="Get all the appenders defined">80 <cffunction name="getAppenders" output="false" access="public" returntype="struct" hint="Get all the appenders defined"> 41 81 <cfreturn instance.appenders> 42 82 </cffunction> 43 83 84 <!------------------------------------------- PRIVATE ------------------------------------------> 85 86 87 <!--- Throw Facade ---> 88 <cffunction name="$throw" access="private" hint="Facade for cfthrow" output="false"> 89 <!--- ************************************************************* ---> 90 <cfargument name="message" type="string" required="yes"> 91 <cfargument name="detail" type="string" required="no" default=""> 92 <cfargument name="type" type="string" required="no" default="Framework"> 93 <!--- ************************************************************* ---> 94 <cfthrow type="#arguments.type#" message="#arguments.message#" detail="#arguments.detail#"> 95 </cffunction> 96 44 97 </cfcomponent> -
coldbox/trunk/testing/cases/logging/LogBoxTest.cfc
r2362 r2363 55 55 logger = logBox.getLogger('MyCat'); 56 56 } 57 57 58 </cfscript> 58 59 </cfcomponent> -
coldbox/trunk/testing/cases/logging/appenders/CFAppenderTest.cfc
r2362 r2363 4 4 cf = getMockBox().createMock(className="coldbox.system.logging.appenders.CFAppender"); 5 5 cf.init('MyCFLogger',0,5); 6 7 loge = getMockBox().createMock(className="coldbox.system.logging.LogEvent"); 8 loge.init("Unit Test Sample",0,structnew(),"UnitTest"); 6 9 } 7 10 8 11 function testLogMessage(){ 9 cf.logMessage( "Unit Test Sample",3);12 cf.logMessage(loge); 10 13 props = {logType="application"}; 11 14 cf.init('MyCFLogger',0,5,props); 12 cf.logMessage( "Application Test Sample",3);15 cf.logMessage(loge); 13 16 } 14 17 </cfscript> -
coldbox/trunk/testing/cases/logging/appenders/ConsoleAppenderTest.cfc
r2362 r2363 4 4 console = getMockBox().createMock(className="coldbox.system.logging.appenders.ConsoleAppender"); 5 5 console.init('MyConsoleAppender',5); 6 7 loge = getMockBox().createMock(className="coldbox.system.logging.LogEvent"); 8 loge.init("Unit Test Sample",0,structnew(),"UnitTest"); 6 9 } 7 10 function testLogMessage(){ 8 11 for(x=0; x lte 5; x++){ 9 console.logMessage("I am sending amessage to the console man",x); 12 loge.setSeverity(x); 13 loge.setCategory("coldbox.system.testing"); 14 console.logMessage(loge); 10 15 } 11 16 } -
coldbox/trunk/testing/cases/logging/appenders/DBAppenderTest.cfc
r2362 r2363 2 2 <cfscript> 3 3 function setup(){ 4 props = {dsn='test mssql',table='logs',autocreate='true'};4 props = {dsn='test',table='logs',autocreate='true'}; 5 5 db = getMockBox().createMock(className="coldbox.system.logging.appenders.DBAppender"); 6 6 db.init('UnitTest',0,5,props); 7 8 loge = getMockBox().createMock(className="coldbox.system.logging.LogEvent"); 9 loge.init("Unit Test Sample",0,structnew(),"UnitTest"); 7 10 } 8 11 … … 18 21 fail('invalid dsn'); 19 22 } 20 catch("DB Logger.DSNException" e){}23 catch("DBAppender.DSNException" e){} 21 24 catch(Any e){ fail(e.message & e.detail);} 22 25 } … … 28 31 29 32 function testLogMessage(){ 30 db.logMessage( "My First Test",1);33 db.logMessage(loge); 31 34 } 32 35 function testLogMessageWithColumnMap(){ … … 37 40 category = "category", 38 41 logdate = "logdate", 39 loggername = "loggername",42 appendername = "appendername", 40 43 messsage = "message" 41 44 }; … … 45 48 fail('map should have failed'); 46 49 } 47 catch("DB Logger.InvalidColumnMapException" e){}50 catch("DBAppender.InvalidColumnMapException" e){} 48 51 catch(any e ){fail(e.message & e.detail);} 49 52 … … 54 57 category = "category", 55 58 logdate = "logdate", 56 loggername = "loggername",59 appendername = "appendername", 57 60 message = "message" 58 61 }; … … 60 63 db.init('UnitTest',0,5,props); 61 64 62 db.logMessage( message="My First Test",severity=1);65 db.logMessage(loge); 63 66 } 64 67 </cfscript> -
coldbox/trunk/testing/cases/logging/appenders/ScopeAppenderTest.cfc
r2362 r2363 5 5 scope = getMockBox().createMock(className="coldbox.system.logging.appenders.ScopeAppender"); 6 6 scope.init('MyScopeLogger',0,5,prop); 7 8 loge = getMockBox().createMock(className="coldbox.system.logging.LogEvent"); 9 loge.init("Unit Test Sample",0,structnew(),"UnitTest"); 7 10 } 8 11 9 12 function testLogMessage(){ 10 scope.logMessage( "Unit Test Sample",3);11 scope.logMessage( "Application Test Sample",0,3, structnew());12 scope.logMessage( "Unit Test Sample",3);13 scope.logMessage(loge); 14 scope.logMessage(loge); 15 scope.logMessage(loge); 13 16 14 17 debug(request); -
coldbox/trunk/testing/cases/logging/config/LogBoxConfigTest.cfc
r2361 r2363 4 4 config = getMockBox().createMock(className="coldbox.system.logging.config.LogBoxConfig").init(); 5 5 } 6 function testAdd (){7 config.add ("luis","coldbox.system.logging.AbstractLogger");8 config.add ("luis2","coldbox.system.logging.AbstractLogger");6 function testAddAppender(){ 7 config.addAppender("luis","coldbox.system.logging.AbstractLogger"); 8 config.addAppender("luis2","coldbox.system.logging.AbstractLogger"); 9 9 10 assertEquals( arraylen(config.getLoggers()), 2); 10 assertEquals( structCount(config.getAppenders()), 2); 11 } 12 function testAddCategory(){ 13 try{ 14 config.addCategory(name="ses",levelMin=0,levelMax=2,appenders="luis,2"); 15 fail("This should have failed."); 16 } 17 catch("LogBoxConfig.AppenderNotFound" e){} 18 catch(Any e){ 19 fail(e.message & e.detail); 20 } 21 22 config.addAppender("luis","coldbox.system.logging.AbstractLogger"); 23 config.addAppender("luis2","coldbox.system.logging.AbstractLogger"); 24 config.addCategory(name="ses",levelMin=0,levelMax=2,appenders="luis,luis2"); 11 25 } 12 26 </cfscript>
