Skip to content

Debugging

Jaime A. Rodriguez edited this page Sep 29, 2020 · 1 revision

The Debug Class

The debug class is a very simple class that makes it easy to write debug messages. Debugging can be turned off and on in the settings.php file depending on the current environment. This is very useful when migrating to the production environment to ensure that all debug messages are hidden from the end-user.

Usage

use \Sleepy\Core\Debug;

Debug::out('Example Message!');

The Debug::out() static method can also take arrays, objects, or anything that can be passed to var_dump.

Types of debug output

There are four ways you can display your debugging information. They are:

  • Output to the screen
  • Output to email
  • Output to a database
  • Output to the Developers Console

Default output

By default, the output is set to be displayed in the Developers Console. This is great because it allows the folding of arrays and objects. This is simply accomplished by json encoding the debug message and wrapping the output in a console.dir().

Database and Email output

The email address and database information can be set up from the settings.php file. These outputs are especially good for use in production environments because they record the errors without notifying the end user of the details. Exposing details of the system is a security risk and so it is disabled by default in the production environment.

Clone this wiki locally