I've tried to raise the following on the Oracle SQL Developer Exchange but an error is stopping me from submitting it:
PRODUCT: SQL Developer
COMPONENT: SQL Formatter
TITLE: Logger: show/hide or dim (highlight) debug/instrumentation code
DESCRIPTION: The oracle open source Logger instrumentation library is gaining popularity and it would be great to build some specific support for it into SQL Developer, whether as a plugin or builtin.
To enhance code readability, it would be helpful for PL/SQL developers to be able to hide/show, or dim (e.g. grey highlight) any code calling their preferred debug/instrumentation library (e.g. Logger).
Refer to https://community.oracle.com/message/14080370#14080370 for one idea for how the editor might look.
One way I expect this might work is that the formatter would be given a configurable list of oracle object identifiers (e.g. "logger", "logger_logs"); any PL/SQL declarations or lines of code containing references to these objects would be greyed out, or be able to be rolled up (with the +/- gutter buttons). - e.g. in the following sample, all code surrounded with [[brackets]] would get this treatment:
create or replace package body pkg_example
gc_scope_prefix constant varchar2(31) := lower($$plsql_unit) || '.';
p_param1_todo in varchar2)
[[ l_scope logger_logs.scope%type := gc_scope_prefix || 'todo_proc_name'; ]]
[[ l_params logger.tab_param; ]]
[[ logger.append_param(l_params, 'p_param1_todo', p_param1_todo); ]]
[[ logger.log('START', l_scope, null, l_params); ]]
,l_scope, null, l_params); ]]
[[ logger.time_reset; ]]
[[ logger.time_start('foo'); ]]
[[ logger.time_stop('foo'); ]]
[[ logger.log('END', l_scope); ]]
when others then
[[ logger.log_error('Unhandled Exception', l_scope, null, l_params); ]]
-- comment referencing logger.package is ignored
I just realised I mis-classified the feature request. This should be a change to the Code Editor - PL/SQL Syntax Colors, not the SQL Formatter.
Jeff Kemp wrote:
2. Add a code generator, that given a function, procedure, or package body (with many functions/procedures), will add all the standard bits to instrument it with Logger - as per the Best Practices document: https://github.com/OraOpenSource/Logger/blob/master/docs/Best%20Practices.md
Thanks, open to discussion on these ideas.
I'll have to keep this in mind when developing Templates (and Generators) for use by oddgen (a template based code generator plugin for SQL*Developer)
A "drag and drop" feature is on the "Enhancement" list.