Skip to content

Instantly share code, notes, and snippets.

@guitrspaz
Last active July 25, 2017 17:54
Show Gist options
  • Save guitrspaz/c26b59a4c4f80c8a6c6fbb0fc426077d to your computer and use it in GitHub Desktop.
Save guitrspaz/c26b59a4c4f80c8a6c6fbb0fc426077d to your computer and use it in GitHub Desktop.
Creates a listener function, which contains defined variables for event and session data.
<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>listener</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