AbstractLogger

Package: MachII.logging.loggers
A logger that configures a logging adapter and performs output of the results if necessary. This is abstract and must be extend by a concrete logger implementation.

<!--- 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: AbstractLogger.cfc 659 2008-03-02 19:28:22Z peterfarrell $ Created version: 1.6.0 Updated version: 1.6.0 Notes: --->

Method Summary
public AbstractLogger init(LogFactory logFactory, struct parameters)

Initializes the logger. Do not override.

public void configure()

Override to provide custom configuration logic. Called after init().

public void disableLogging()

Disables logging. Convenience method for dashboard.

public void enableLogging()

Enables logging. Convenience method for dashboard.

private AbstractLogAdapter getLogAdapter()

Gets the log adapter for this logger.

private LogFactory getLogFactory()

Gets the log factory for this logger.

public string getLoggerType()

Returns the type of the logger. Required for Dashboard integration.

public any getParameter(string name, [string defaultValue=""])

Gets a configuration parameter value, or a default value if not defined.

public struct getParameters()

Gets the full set of configuration parameters for the component.

public boolean isOnRequestEndAvailable()

Checks if on request end method is available.

public boolean isParameterDefined(string name)

Checks to see whether or not a configuration parameter is defined.

public boolean isPrePostRedirectAvailable()

Checks if pre/post-redirect methods are available.

public void onRequestEnd()

On request end logic for this logger. Override to provide custom on request end logic.

public void postRedirect(struct data)

Post-redirect logic for this logger. Override to provide custom post-redirect logic.

public void preRedirect(struct data)

Pre-redirect logic for this logger. Override to provide custom pre-redirect logic.

private void setLogAdapter(AbstractLogAdapter logAdapter)

Sets the log adapter for this logger.

private void setLogFactory(LogFactory logFactory)

Sets the log factory for this logger.

public void setParameter(string name, any value)

Sets a configuration parameter.

public void setParameters(struct parameters)

Sets the full set of configuration parameters for the component.

Method Detail
configure

public void configure( )

Override to provide custom configuration logic. Called after init().

Parameters:

Code:

	<cffunction name="configure" access="public" returntype="void" output="false"
		hint="Override to provide custom configuration logic. Called after init().">
		
	</cffunction> 

disableLogging

public void disableLogging( )

Disables logging. Convenience method for dashboard.

Parameters:

Code:

	<cffunction name="disableLogging" access="public" returntype="void" output="false"
		hint="Disables logging. Convenience method for dashboard.">
		<cfset getLogAdapter().setLoggingEnabled(false) />
	</cffunction> 

enableLogging

public void enableLogging( )

Enables logging. Convenience method for dashboard.

Parameters:

Code:

	<cffunction name="enableLogging" access="public" returntype="void" output="false"
		hint="Enables logging. Convenience method for dashboard.">
		<cfset getLogAdapter().setLoggingEnabled(true) />
	</cffunction> 

getLogAdapter

private AbstractLogAdapter getLogAdapter( )

Gets the log adapter for this logger.

Parameters:

Code:

	<cffunction name="getLogAdapter" access="private" returntype="MachII.logging.adapters.AbstractLogAdapter" output="false"
		hint="Gets the log adapter for this logger.">
		<cfreturn variables.logAdapter />
	</cffunction> 

getLogFactory

private LogFactory getLogFactory( )

Gets the log factory for this logger.

Parameters:

Code:

	<cffunction name="getLogFactory" access="private" returntype="MachII.logging.LogFactory" output="false"
		hint="Gets the log factory for this logger.">
		<cfreturn variables.logFactory />
	</cffunction> 

getLoggerType

public string getLoggerType( )

Returns the type of the logger. Required for Dashboard integration.

Parameters:

Code:

	<cffunction name="getLoggerType" access="public" returntype="string" output="false"
		hint="Returns the type of the logger. Required for Dashboard integration.">
		<cfreturn variables.loggerType />
	</cffunction> 

getParameter

public any getParameter( string name, [string defaultValue=""] )

Gets a configuration parameter value, or a default value if not defined.

Parameters:
string name
[string defaultValue=""]

Code:

	<cffunction name="getParameter" access="public" returntype="any" output="false"
		hint="Gets a configuration parameter value, or a default value if not defined.">
		<cfargument name="name" type="string" required="true"
			hint="The parameter name." />
		<cfargument name="defaultValue" type="string" required="false" default=""
			hint="The default value to return if the parameter is not defined. Defaults to a blank string." />
		<cfif isParameterDefined(arguments.name)>
			<cfreturn variables.parameters[arguments.name] />
		<cfelse>
			<cfreturn arguments.defaultValue />
		</cfif>
	</cffunction> 

getParameters

public struct getParameters( )

Gets the full set of configuration parameters for the component.

Parameters:

Code:

	<cffunction name="getParameters" access="public" returntype="struct" output="false"
		hint="Gets the full set of configuration parameters for the component.">
		<cfreturn variables.parameters />
	</cffunction> 

init

public AbstractLogger init( LogFactory logFactory, struct parameters )

Initializes the logger. Do not override.

Parameters:
LogFactory logFactory
struct parameters

Code:

	<cffunction name="init" access="public" returntype="AbstractLogger" output="false"
		hint="Initializes the logger. Do not override.">
		<cfargument name="logFactory" type="MachII.logging.LogFactory" required="true" />
		<cfargument name="parameters" type="struct" required="true" />
		
		<cfset setLogFactory(arguments.logFactory) />
		<cfset setParameters(arguments.parameters) />
		
		<cfreturn this />
	</cffunction> 

isOnRequestEndAvailable

public boolean isOnRequestEndAvailable( )

Checks if on request end method is available.

Parameters:

Code:

	<cffunction name="isOnRequestEndAvailable" access="public" returntype="boolean" output="false"
		hint="Checks if on request end method is available.">
		<cfreturn variables.onRequestEndAvailable />
	</cffunction> 

isParameterDefined

public boolean isParameterDefined( string name )

Checks to see whether or not a configuration parameter is defined.

Parameters:
string name

Code:

	<cffunction name="isParameterDefined" access="public" returntype="boolean" output="false"
		hint="Checks to see whether or not a configuration parameter is defined.">
		<cfargument name="name" type="string" required="true"
			hint="The parameter name." />
		<cfreturn StructKeyExists(variables.parameters, arguments.name) />
	</cffunction> 

isPrePostRedirectAvailable

public boolean isPrePostRedirectAvailable( )

Checks if pre/post-redirect methods are available.

Parameters:

Code:

	<cffunction name="isPrePostRedirectAvailable" access="public" returntype="boolean" output="false"
		hint="Checks if pre/post-redirect methods are available.">
		<cfreturn variables.prePostRedirectAvailable />
	</cffunction> 

onRequestEnd

public void onRequestEnd( )

On request end logic for this logger. Override to provide custom on request end logic.

Parameters:

Code:

	<cffunction name="onRequestEnd" access="public" returntype="void" 
		hint="On request end logic for this logger. Override to provide custom on request end logic.">
		
		<cfabort showerror="This method is abstract and must be overrided." />
	</cffunction> 

postRedirect

public void postRedirect( struct data )

Post-redirect logic for this logger. Override to provide custom post-redirect logic.

Parameters:
struct data

Code:

	<cffunction name="postRedirect" access="public" returntype="void" output="false"
		hint="Post-redirect logic for this logger. Override to provide custom post-redirect logic.">
		<cfargument name="data" type="struct" required="true"
			hint="Redirect persist data struct." />
		<cfabort showerror="This method is abstract and must be overrided." />
	</cffunction> 

preRedirect

public void preRedirect( struct data )

Pre-redirect logic for this logger. Override to provide custom pre-redirect logic.

Parameters:
struct data

Code:

	<cffunction name="preRedirect" access="public" returntype="void" output="false"
		hint="Pre-redirect logic for this logger. Override to provide custom pre-redirect logic.">
		<cfargument name="data" type="struct" required="true"
			hint="Redirect persist data struct." />
		<cfabort showerror="This method is abstract and must be overrided." />
	</cffunction> 

setLogAdapter

private void setLogAdapter( AbstractLogAdapter logAdapter )

Sets the log adapter for this logger.

Parameters:
AbstractLogAdapter logAdapter

Code:

	<cffunction name="setLogAdapter" access="private" returntype="void" output="false"
		hint="Sets the log adapter for this logger.">
		<cfargument name="logAdapter" type="MachII.logging.adapters.AbstractLogAdapter" required="true" />
		<cfset variables.logAdapter = arguments.logAdapter />
	</cffunction> 

setLogFactory

private void setLogFactory( LogFactory logFactory )

Sets the log factory for this logger.

Parameters:
LogFactory logFactory

Code:

	<cffunction name="setLogFactory" access="private" returntype="void" output="false"
		hint="Sets the log factory for this logger.">
		<cfargument name="logFactory" type="MachII.logging.LogFactory" required="true" />
		<cfset variables.logFactory = arguments.logFactory />
	</cffunction> 

setParameter

public void setParameter( string name, any value )

Sets a configuration parameter.

Parameters:
string name
any value

Code:

	<cffunction name="setParameter" access="public" returntype="void" output="false"
		hint="Sets a configuration parameter.">
		<cfargument name="name" type="string" required="true"
			hint="The parameter name." />
		<cfargument name="value" required="true"
			hint="The parameter value." />
		<cfset variables.parameters[arguments.name] = arguments.value />
	</cffunction> 

setParameters

public void setParameters( struct parameters )

Sets the full set of configuration parameters for the component.

Parameters:
struct parameters

Code:

	<cffunction name="setParameters" access="public" returntype="void" output="false"
		hint="Sets the full set of configuration parameters for the component.">
		<cfargument name="parameters" type="struct" required="true" />
		
		<cfset var key = "" />
		
		<cfloop collection="#arguments.parameters#" item="key">
			<cfset setParameter(key, parameters[key]) />
		</cfloop>
	</cffunction>