Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to do an apex.debug call automatically when calling logger.log #217

Open
3 tasks
martindsouza opened this issue Jun 11, 2018 · 6 comments
Open
3 tasks
Assignees
Milestone

Comments

@martindsouza
Copy link
Member

martindsouza commented Jun 11, 2018

Clients would like to see their logs logged in APEX at the same time. This is redundant but helps when looking at the session debug in APEX.

Thanks to @dgielis for suggestion

  • Optional parameter
  • Need to verify how apex.debug changes in each version of APEX
  • Test to see the affects of when apex.debug is enabled vs disabled. This should not affect calls to logger.log
@martindsouza martindsouza added this to the 3.2.0 milestone Jun 11, 2018
@martindsouza martindsouza self-assigned this Jun 11, 2018
@martindsouza
Copy link
Member Author

martindsouza commented Jun 18, 2018

@dgielis How do you think I should handle the following situation:

  • Logger level is set to error (i.e. similar to production situation)
  • APEX developer logs in and runs their app in APEX debug mode

Should calls to logger.log be logged? If yes then we'd need to factor the following:

  • How APEX levels map to Logger levels
  • When checking if a statement should be logged need to check both Logger and APEX levels
    • Need to check performance impacts of this
    • This would need to be triggered by session specific logging
    • Would need to "turn this off" when APEX debug is off.

@jeffreykemp
Copy link

jeffreykemp commented Jun 19, 2018

apex_debug, by default, does not store a log message if the page is not rendered in debug mode, or if the p_level is greater than the selected apex debug messaging level (there is an optional "force" parameter that can override this but you would not use it).

https://docs.oracle.com/database/apex-5.1/AEAPI/MESSAGE-Procedure.htm#AEAPI29228
https://docs.oracle.com/database/apex-5.1/AEAPI/Constants-2.htm#AEAPI29184

Suggested mapping:

if logger_level = g_permanent then

  /* apex_debug.error always logs, even if debug mode is turned off */
  apex_debug.error(p_message => l_message);

else

  l_apex_level :=
    case logger_level
    when g_error       then apex_debug.c_log_level_error /* [level 1] */
    when g_warning     then apex_debug.c_log_level_warn /* [level 2] */
    when g_information then apex_debug.c_log_level_info /* [level 4] */
                       else apex_debug.c_log_level_app_trace /* [level 6] */
    end;
    /* not used: apex_debug.c_log_level_app_enter [level 5] */

  apex_debug.message
    (p_message => l_message
    ,p_level   => l_apex_level);

end if;

@jeffreykemp
Copy link

Is this not a duplicate of #158?

@dgielis
Copy link

dgielis commented Jun 19, 2018

like the mapping of Jeff.

Also note that in APEX you can do apex_debug.message('hello %s','Martin');
How would that be translated into logger?

@eaolson
Copy link

eaolson commented Jun 20, 2018

This seems out of scope for Logger and tightly couples Logger to Apex (though I imaging conditional compilation would fix that). I would suggest a better solution would be to wrap logger and apex.debug calls in a custom procedure. I added a Logger call to our custom error logging procedure when we started using it.

@SvenWeller
Copy link

@dgielis How do you think I should handle the following situation:

Logger level is set to error (i.e. similar to production situation)
APEX developer logs in and runs their app in APEX debug mode
Should calls to logger.log be logged? If yes then we'd need to factor the following:

Here is how I think, it could work.
If APEX logging is configured (logger_prefs), then two fairly independend logging checks need to be made. One for the primary logging mode, one for the apex logging mode.

The subprogram that is called (log_error vs. log_trace) decides the logging level.
Currently we seem not to have direct access to the apex debug level. So it is not possible to use that inside logger directly. Fortunatly we don't need it.
If logger.log_error is called, then also call apex_debug.error. If logger.log_trace is called, call apex_debug.trace. The call to the apex_debug subprograms must not be dependend on the logger log_level settings. They already do depend on the apex log level settings (internal logic).

Yes there will be a negative performance impact because for the additional subprogram call and the check for the apex log level.

The apex_debug calls of cause are rendered there using conditional compiling. So this negative performance effect would only exist in an apex environment. In most APEX applications this slight performance slowdown would be acceptable. Other environments where performance is extremely critical will not need to configure this apex_debug setting.

However it also means we can not easily configure this on an application level, unless we have a separate logger installation for each (apex) application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants