Skip to content

Logging

Stephen Vickers edited this page Jul 31, 2023 · 5 revisions

The Util class includes a static property named logLevel which can be used to control the sending of log messages to the PHP error log. This property should be given one of four values defined by the ceLTIc\LTI\Enum\LogLevel enumeration (or constants in the Util class for version 4 or earlier). One of four values should be used:

Enumeration value Description
LogLevel::None No log messages are recorded (this is the default setting)
LogLevel::Error Only logs of errors are recorded
LogLevel::Info All error and information log messages are recorded
LogLevel::Debug All log messages are recorded

In version 4 (and earlier), use one of the constants defined in the ceLTIc\LTI\Util class:

Constant name Description
LOGLEVEL_NONE No log messages are recorded (this is the default setting)
LOGLEVEL_ERROR Only logs of errors are recorded
LOGLEVEL_INFO All error and information log messages are recorded
LOGLEVEL_DEBUG All log messages are recorded

By default, no messages are logged. To change this include a line such as the following before any messages or service requests are processed:

use ceLTIc\LTI\Enum\LogLevel;

...

Util::$logLevel = LogLevel::Debug;

or, for version 4 and earlier:

use ceLTIc\LTI\Util;

...

Util::$logLevel = Util::LOGLEVEL_DEBUG;

The following methods include logging events:

  • Tool->handleRequest:
    • details of the request received (LogLevel::Info)
    • reason for any error with the request (LogLevel::Error)
  • 'Http\HttpMessage->send' (LogLevel::Info when successful, LogLevel::Error when unsuccessful):
    • details of the request being sent (URL and POST parameters or message body)
    • the response received (headers and any message body)
  • DataConnector\DataConnector sub-classes:
    • SQL statements executed (LogLevel::Debug when successful, LogLevel::Error when unsuccessful)

Debug-level logging is also enabled when the debugMode property of the Tool or Platform object in use is set to true. When enabled, this setting will override the currently defined log level. See the Usage section for more information.

Clone this wiki locally