Debugging in Moodle

Debugging in Moodle

لە لایەن Eric Richer -
Number of replies: 2

Hey folks,

In my experience, it's not uncommon for developers to use some kind of logging API to which they can send debugging statements to help in the supportability of their software.

To this extent, Moodle does have the function \debugging which appears to be useful for this purpose.

With that being said, I am noticing that when running unit tests, if any call to \debugging is made over the course of the execution of the test, the test will fail.

Am I mis-interpreting the purpose of \debugging?  Is it really only intended to be used to log errors?


تێکرایى نمرەپێدراوەکان: -
In reply to Eric Richer

Re: Debugging in Moodle

لە لایەن Mark Johnson -
وێنەی Core developers وێنەی Particularly helpful Moodlers وێنەی Peer reviewers وێنەی Plugin developers

Moodle's logging API is tied to events. When you trigger an event, it can be handled by multiple handlers, but it will always be captured and logged by the logging system.

As I understand it, debugging() is intended to output additional information when there is an error, not for silently logging. Unit tests capture debugging calls and can assert particular calls or the number of times it was called with assertDebuggingCalled() and assertDebuggingCalledCount(), so that you can test errors are being reported as desired.

You can also set up interactive debugging with XDebug.