Forked from guitrspaz/listenerFunction.sublime-snippet
Last active
August 24, 2017 14:22
-
-
Save obxpete/1dd73f24e5f2aa6d85348273a753b631 to your computer and use it in GitHub Desktop.
Creates a listener function, which contains defined variables for event and session data.
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
<snippet> | |
<content><![CDATA[/** | |
* @name: ${TM_FILENAME/(.+)\..+|.*/$1/:name}.${1:functionName} | |
* @hint: ${2:Description} | |
* @returns: ${3:Any} | |
* @date: ${4:Date} | |
* @author: $TM_FULLNAME ($TM_EMAIL) | |
*/ | |
${5:public} ${3:Any} function ${1:functionName}( | |
required MachII.Framework.Event event | |
){ | |
var args=arguments.event.getArgs(); | |
var monolithSession=arguments.event.getArg('monolithSession').getSnapShot(); | |
var errorStruct={ | |
arguments:args, | |
logType:"warning", | |
start:Now(), | |
stackTrace:getStackTrace(), | |
result:${6:{}} | |
}; | |
try{ | |
errorStruct.logType="information"; | |
} catch( Any e ){ | |
errorStruct.logType="error"; | |
errorStruct.cfcatch=e; | |
} | |
errorStruct.end=Now(); | |
errorStruct.diff=DateDiff('s',errorStruct.start,errorStruct.end); | |
if( errorStruct.logType!='information' || this.getdebugMode() ){ | |
createLog( | |
logName=this.getdefaultLog(), | |
logType=errorStruct.logType, | |
functName=this.getcaller()&".${1:functionName}()", | |
args=errorStruct | |
); | |
} | |
return errorStruct.result; | |
} | |
]]></content> | |
<!-- Optional: Set a tabTrigger to define how to trigger the snippet --> | |
<tabTrigger>listenerFunc</tabTrigger> | |
<!-- Optional: Set a scope to limit where the snippet will trigger --> | |
<!-- <scope>source.python</scope> --> | |
</snippet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment