Skip to content

Instantly share code, notes, and snippets.

@hhudson
Last active November 9, 2023 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hhudson/9bd526114da59263924282d33d81e073 to your computer and use it in GitHub Desktop.
Save hhudson/9bd526114da59263924282d33d81e073 to your computer and use it in GitHub Desktop.
Javascript apex debug snippets
{
"ad 0.0 create session": {
"prefix": "ad create session",
"body": [
"apex_session.create_session(p_app_id=>$1,p_page_id=>$2,p_username=>'HHH');"
],
"description": "Create session to run outside of apex"
},
"ad 0.1 enable debug": {
"prefix": "ad enable debug",
"body": ["apex_debug.enable(p_level => apex_debug.c_log_level_info);"],
"description": "Enable debug to run outside of apex"
},
"ad 0.2 declare gc_scope_prefix": {
"prefix": "ad gc_scope_prefix",
"body": ["gc_scope_prefix constant varchar2(41) := lower($$plsql_unit) || '.';"],
"description": "declare gc_scope_prefix"
},
"ad 1.0 declare template": {
"prefix": "ad declare template",
"body": [
"c_scope constant varchar2(128) := gc_scope_prefix || '$1';",
"c_debug_template constant varchar2(4000) := c_scope||' %0 %1 %2 %3 %4 %5 %6 %7';"
],
"description": "Declare a debug template"
},
"ad 2.0 start message": {
"prefix": "ad start message",
"body": [
"apex_debug.message(c_debug_template,'START',",
" 'p_first_name', p_first_name",
" );"
],
"description": "Start message (after begin)"
},
"ad 3.0 info": {
"prefix": "ad info",
"body": ["apex_debug.info(c_debug_template, '$1', $2);"],
"description": "Add an info message (level 4)"
},
"ad 3.2 warn": {
"prefix": "ad warn",
"body": ["apex_debug.warn(c_debug_template,'$1', $2);"],
"description": "Add a warning message (level 2)"
},
"ad 3.3 error": {
"prefix": "ad exception",
"body": [
"exception",
" when others then",
" apex_debug.error(p_message => c_debug_template, p0 =>'Unhandled Exception', p1 => sqlerrm, p5 => sqlcode, p6 => dbms_utility.format_error_stack, p7 => dbms_utility.format_error_backtrace, p_max_length=> 4096);",
" raise;"
],
"description": "Add an error message (level 1)"
},
"proc body": {
"prefix": "as begin end (proc body)",
"body": [
"as",
"c_scope constant varchar2(128) := gc_scope_prefix || '$1';",
"c_debug_template constant varchar2(4000) := c_scope||' %0 %1 %2 %3 %4 %5 %6 %7';"
"begin",
" apex_debug.message(c_debug_template,'START',",
" 'p_first_name', p_first_name",
" );",
" ",
"exception",
" when others then",
" apex_debug.error(p_message => c_debug_template, p0 =>'Unhandled Exception', p1 => sqlerrm, p5 => sqlcode, p6 => dbms_utility.format_error_stack, p7 => dbms_utility.format_error_backtrace, p_max_length=> 4096);",
" raise;"
"end $1;"
],
"description": "Add an error message (level 1)"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment