Created
November 22, 2013 18:13
-
-
Save sigmaprojects/7604389 to your computer and use it in GitHub Desktop.
An Async Logger appender for BugLogHQ.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfcomponent extends="model.loggers.appenders.BugLogHQAppender" | |
output="false" | |
hint="This is a simple implementation of a appender that is BugLogHQ based."> | |
<!--- Init ---> | |
<cffunction name="init" access="public" returntype="DBAppender" hint="Constructor" output="false" > | |
<!--- ************************************************************* ---> | |
<cfargument name="name" required="true" hint="The unique name for this appender."/> | |
<cfargument name="properties" required="false" default="#structnew()#" hint="A map of configuration properties for the appender"/> | |
<cfargument name="layout" required="false" default="" hint="The layout class to use in this appender for custom message rendering."/> | |
<cfargument name="levelMin" required="false" default="0" hint="The default log level for this appender, by default it is 0. Optional. ex: LogBox.logLevels.WARN"/> | |
<cfargument name="levelMax" required="false" default="4" hint="The default log level for this appender, by default it is 5. Optional. ex: LogBox.logLevels.WARN"/> | |
<!--- ************************************************************* ---> | |
<cfscript> | |
// Init supertype | |
super.init(argumentCollection=arguments); | |
// strong reference to super scope if not cf9 and below choke on high load and cfthread | |
variables.$super = super; | |
return this; | |
</cfscript> | |
</cffunction> | |
<!--- Log Message ---> | |
<cffunction name="logMessage" access="public" output="false" returntype="void" hint="Write an entry into the appender."> | |
<!--- ************************************************************* ---> | |
<cfargument name="logEvent" type="any" required="true" hint="The logging event"/> | |
<!--- ************************************************************* ---> | |
<cfscript> | |
var uuid = createobject("java", "java.util.UUID").randomUUID(); | |
var threadName = "#getname()#_logMessage_#replace(uuid,"-","","all")#"; | |
</cfscript> | |
<!--- Are we in a thread already? ---> | |
<cfif getUtil().inThread()> | |
<cfset super.logMessage(arguments.logEvent)> | |
<cfelse> | |
<!--- Thread this puppy ---> | |
<cfthread name="#threadName#" logEvent="#arguments.logEvent#"> | |
<cfset variables.$super.logMessage(attributes.logEvent)> | |
</cfthread> | |
</cfif> | |
</cffunction> | |
<!------------------------------------------- PRIVATE ------------------------------------------> | |
</cfcomponent> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment