| Package: MachII.logging |
| A simple logging API. |
<!--- License: Copyright 2008 GreatBizTools, LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Copyright: GreatBizTools, LLC Author: Peter J. Farrell (peter@mach-ii.com) $Id: Log.cfc 920 2008-07-28 16:26:57Z peterfarrell $ Created version: 1.6.0 Updated version: 1.6.0 Notes: Mach-II Logging is heavily based on Apache Commons Logging interface. ---> |
| Method Summary | |
|---|---|
| public Log |
init(string channel, struct logAdapters)
Initializes the logging facade. |
| public void |
debug(string message, [any additionalInformation])
Logs a message with debug log level. |
| public void |
error(string message, [any additionalInformation])
Logs a message with error log level. |
| public void |
fatal(string message, [any additionalInformation])
Logs a message with fatal log level. |
| public string |
getChannel()
Returns the channel. |
| public struct |
getLogAdapters()
Returns the log adapters. |
| public void |
info(string message, [any additionalInformation])
Logs a message with info log level. |
| public boolean |
isDebugEnabled()
Checks if debug level logging is enabled. |
| public boolean |
isErrorEnabled()
Checks if error level logging is enabled. |
| public boolean |
isFatalEnabled()
Checks if fatal level logging is enabled. |
| public boolean |
isInfoEnabled()
Checks if info level logging is enabled. |
| public boolean |
isTraceEnabled()
Checks if trace level logging is enabled. |
| public boolean |
isWarnEnabled()
Checks if warn level logging is enabled. |
| private void |
setChannel(string channel)
Sets the channel. |
| private void |
setLogAdapters(struct logAdapters)
Sets the log adapters. |
| public void |
trace(string message, [any additionalInformation])
Logs a message with trace log level. |
| public void |
warn(string message, [any additionalInformation])
Logs a message with warn log level. |
| Method Detail |
|---|
| debug |
|---|
public void debug( string message, [any additionalInformation] )
Logs a message with debug log level.
Parameters:
| string message |
| [any additionalInformation] |
Code:
<cffunction name="debug" access="public" returntype="void" output="false" hint="Logs a message with debug log level."> <cfargument name="message" type="string" required="true" /> <cfargument name="additionalInformation" type="any" required="false" /> <cfset var key = "" /> <cfloop collection="#variables.logAdapters#" item="key"> <cfif StructKeyExists(arguments, "additionalInformation")> <cfset variables.logAdapters[key].debug(getChannel(), arguments.message, arguments.additionalInformation) /> <cfelse> <cfset variables.logAdapters[key].debug(getChannel(), arguments.message) /> </cfif> </cfloop> </cffunction>
| error |
|---|
public void error( string message, [any additionalInformation] )
Logs a message with error log level.
Parameters:
| string message |
| [any additionalInformation] |
Code:
<cffunction name="error" access="public" returntype="void" output="false" hint="Logs a message with error log level."> <cfargument name="message" type="string" required="true" /> <cfargument name="additionalInformation" type="any" required="false" /> <cfset var key = "" /> <cfloop collection="#variables.logAdapters#" item="key"> <cfif StructKeyExists(arguments, "additionalInformation")> <cfset variables.logAdapters[key].error(getChannel(), arguments.message, arguments.additionalInformation) /> <cfelse> <cfset variables.logAdapters[key].error(getChannel(), arguments.message) /> </cfif> </cfloop> </cffunction>
| fatal |
|---|
public void fatal( string message, [any additionalInformation] )
Logs a message with fatal log level.
Parameters:
| string message |
| [any additionalInformation] |
Code:
<cffunction name="fatal" access="public" returntype="void" output="false" hint="Logs a message with fatal log level."> <cfargument name="message" type="string" required="true" /> <cfargument name="additionalInformation" type="any" required="false" /> <cfset var key = "" /> <cfloop collection="#variables.logAdapters#" item="key"> <cfif StructKeyExists(arguments, "additionalInformation")> <cfset variables.logAdapters[key].fatal(getChannel(), arguments.message, arguments.additionalInformation) /> <cfelse> <cfset variables.logAdapters[key].fatal(getChannel(), arguments.message) /> </cfif> </cfloop> </cffunction>
| getChannel |
|---|
public string getChannel( )
Returns the channel.
Parameters:
Code:
<cffunction name="getChannel" access="public" returntype="string" output="false" hint="Returns the channel."> <cfreturn variables.channel /> </cffunction>
| getLogAdapters |
|---|
public struct getLogAdapters( )
Returns the log adapters.
Parameters:
Code:
<cffunction name="getLogAdapters" access="public" returntype="struct" output="false" hint="Returns the log adapters."> <cfreturn variables.logAdapters /> </cffunction>
| info |
|---|
public void info( string message, [any additionalInformation] )
Logs a message with info log level.
Parameters:
| string message |
| [any additionalInformation] |
Code:
<cffunction name="info" access="public" returntype="void" output="false" hint="Logs a message with info log level."> <cfargument name="message" type="string" required="true" /> <cfargument name="additionalInformation" type="any" required="false" /> <cfset var key = "" /> <cfloop collection="#variables.logAdapters#" item="key"> <cfif StructKeyExists(arguments, "additionalInformation")> <cfset variables.logAdapters[key].info(getChannel(), arguments.message, arguments.additionalInformation) /> <cfelse> <cfset variables.logAdapters[key].info(getChannel(), arguments.message) /> </cfif> </cfloop> </cffunction>
| init |
|---|
public Log init( string channel, struct logAdapters )
Initializes the logging facade.
Parameters:
| string channel |
| struct logAdapters |
Code:
<cffunction name="init" access="public" returntype="Log" output="false" hint="Initializes the logging facade."> <cfargument name="channel" type="string" required="true" /> <cfargument name="logAdapters" type="struct" required="true" /> <cfset setChannel(arguments.channel) /> <cfset setLogAdapters(arguments.logAdapters) /> <cfreturn this /> </cffunction>
| isDebugEnabled |
|---|
public boolean isDebugEnabled( )
Checks if debug level logging is enabled.
Parameters:
Code:
<cffunction name="isDebugEnabled" access="public" returntype="boolean" output="false" hint="Checks if debug level logging is enabled."> <cfset var key = "" /> <cfloop collection="#variables.logAdapters#" item="key"> <cfif variables.logAdapters[key].isDebugEnabled()> <cfreturn true /> </cfif> </cfloop> <cfreturn false /> </cffunction>
| isErrorEnabled |
|---|
public boolean isErrorEnabled( )
Checks if error level logging is enabled.
Parameters:
Code:
<cffunction name="isErrorEnabled" access="public" returntype="boolean" output="false" hint="Checks if error level logging is enabled."> <cfset var key = "" /> <cfloop collection="#variables.logAdapters#" item="key"> <cfif variables.logAdapters[key].isErrorEnabled()> <cfreturn true /> </cfif> </cfloop> <cfreturn false /> </cffunction>
| isFatalEnabled |
|---|
public boolean isFatalEnabled( )
Checks if fatal level logging is enabled.
Parameters:
Code:
<cffunction name="isFatalEnabled" access="public" returntype="boolean" output="false" hint="Checks if fatal level logging is enabled."> <cfset var key = "" /> <cfloop collection="#variables.logAdapters#" item="key"> <cfif variables.logAdapters[key].isFatalEnabled()> <cfreturn true /> </cfif> </cfloop> <cfreturn false /> </cffunction>
| isInfoEnabled |
|---|
public boolean isInfoEnabled( )
Checks if info level logging is enabled.
Parameters:
Code:
<cffunction name="isInfoEnabled" access="public" returntype="boolean" output="false" hint="Checks if info level logging is enabled."> <cfset var key = "" /> <cfloop collection="#variables.logAdapters#" item="key"> <cfif variables.logAdapters[key].isInfoEnabled()> <cfreturn true /> </cfif> </cfloop> <cfreturn false /> </cffunction>
| isTraceEnabled |
|---|
public boolean isTraceEnabled( )
Checks if trace level logging is enabled.
Parameters:
Code:
<cffunction name="isTraceEnabled" access="public" returntype="boolean" output="false" hint="Checks if trace level logging is enabled."> <cfset var key = "" /> <cfloop collection="#variables.logAdapters#" item="key"> <cfif variables.logAdapters[key].isTraceEnabled()> <cfreturn true /> </cfif> </cfloop> <cfreturn false /> </cffunction>
| isWarnEnabled |
|---|
public boolean isWarnEnabled( )
Checks if warn level logging is enabled.
Parameters:
Code:
<cffunction name="isWarnEnabled" access="public" returntype="boolean" output="false" hint="Checks if warn level logging is enabled."> <cfset var key = "" /> <cfloop collection="#variables.logAdapters#" item="key"> <cfif variables.logAdapters[key].isWarnEnabled()> <cfreturn true /> </cfif> </cfloop> <cfreturn false /> </cffunction>
| setChannel |
|---|
private void setChannel( string channel )
Sets the channel.
Parameters:
| string channel |
Code:
<cffunction name="setChannel" access="private" returntype="void" output="false" hint="Sets the channel."> <cfargument name="channel" type="string" required="true" /> <cfset variables.channel = arguments.channel /> </cffunction>
| setLogAdapters |
|---|
private void setLogAdapters( struct logAdapters )
Sets the log adapters.
Parameters:
| struct logAdapters |
Code:
<cffunction name="setLogAdapters" access="private" returntype="void" output="false" hint="Sets the log adapters."> <cfargument name="logAdapters" type="struct" required="true" /> <cfset variables.logAdapters = arguments.logAdapters /> </cffunction>
| trace |
|---|
public void trace( string message, [any additionalInformation] )
Logs a message with trace log level.
Parameters:
| string message |
| [any additionalInformation] |
Code:
<cffunction name="trace" access="public" returntype="void" output="false" hint="Logs a message with trace log level."> <cfargument name="message" type="string" required="true" /> <cfargument name="additionalInformation" type="any" required="false" /> <cfset var key = "" /> <cfloop collection="#variables.logAdapters#" item="key"> <cfif StructKeyExists(arguments, "additionalInformation")> <cfset variables.logAdapters[key].trace(getChannel(), arguments.message, arguments.additionalInformation) /> <cfelse> <cfset variables.logAdapters[key].trace(getChannel(), arguments.message) /> </cfif> </cfloop> </cffunction>
| warn |
|---|
public void warn( string message, [any additionalInformation] )
Logs a message with warn log level.
Parameters:
| string message |
| [any additionalInformation] |
Code:
<cffunction name="warn" access="public" returntype="void" output="false" hint="Logs a message with warn log level."> <cfargument name="message" type="string" required="true" /> <cfargument name="additionalInformation" type="any" required="false" /> <cfset var key = "" /> <cfloop collection="#variables.logAdapters#" item="key"> <cfif StructKeyExists(arguments, "additionalInformation")> <cfset variables.logAdapters[key].warn(getChannel(), arguments.message, arguments.additionalInformation) /> <cfelse> <cfset variables.logAdapters[key].warn(getChannel(), arguments.message) /> </cfif> </cfloop> </cffunction>