setting exceptionLogAdapterConfig in variables.framework

11 views
Skip to first unread message

Timothy Lux

unread,
Apr 24, 2016, 11:48:42 PM4/24/16
to Taffy Users
The examples show my app's application.cfc is supposed to set the variables.framework in the constructor, which runs for every request, correct?
An issue I have is that I need to set the emailTo config setting of exceptionLogAdapterConfig based on the environment, but can't hardcode it behind the environments framework key.
I can't find an elegant way around this.

My app is setup with a "thisServer.cfm" file which sets the machineID and exceptionEmail into the server scope. That lets us define that differently for each dev machine, prod machine, etc.
I include that file in the application.cfc's getEnvironment method so I can set the environment value, but I don't want to put the include in the application.cfc constructor itself as it doesn't need to run every request.

Is the best solution here some sort of scope caching? Should I do something like:

<cfcomponent extends="taffy.core.api" output="false">
     <cfset this.name = hash(getCurrentTemplatePath())>
     <cfif isDefined("application.frameworkVars")>
          <cfset variables.framework = application.frameworkVars>
     <cfelse>
          <cfset variables.framework = loadFrameworkVars()>
     </cfif>

     <cffunction name="loadFrameworkVars" access="private" returnType="struct" output="false">
          <cfinclude template="thisServer.cfm">
          <cfset application.framework = {
               some vars here, including the exceptionLogAdapterConfig struct which uses server variables
          }>
          <cfreturn application.framework>
     </cffunction>
</cfcomponent>

or would it work to set the variables.framework from inside my onApplicationStart, which is already setup to include that file for other reasons?

At what point is the variables.framework actually loaded?

Tim

Timothy Lux

unread,
Apr 24, 2016, 11:59:25 PM4/24/16
to Taffy Users
Incidentally, It seems to be working right now by this method:
- in my onApplicationStart, set the framework vars into application scope, then set variables.framework = application.frameworkVars.

Not sure if that is the "preferred" way though.

Adam Tuttle

unread,
Apr 25, 2016, 6:16:48 AM4/25/16
to Taffy Users

Variables.framework is copied to an application variable called application._taffy in the framework's onApplicationStart method.

As long as the value you need is in variables.framework before you call super.onApplicationStart then you're doing it right.

--
You received this message because you are subscribed to the Google Groups "Taffy Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to taffy-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages