Grav – Debugging & Logging

  • Post author:
  • Post category:Grav
  • Post comments:1 Comment
Debugging & logging

Debugging & logging information is very necessary while developing the themes and plugins. Grav uses the debugging information by using some features as described below.

PHP Debug Bar

Grav comes with a tool called the Debug Bar to display debugging information. By default, this feature is disabled. You can turn it on globally or use system.yaml for your development environment.

debugger:
   enabled: true
   twig: true
   shutdown:
      close_connection: true

After enabling the debugger true, you can view the following debug bar as shown below. Click on the G symbol which is present at the left side of the corner.

Debugging & logging

In the debug bar, you can view the overall memory usage and the time used for processing at the corner on the right side. It also consists several tabs that provide information in detail.

In the Messages tab, you can view the messages which will help you to debug your Grav development process and the information will get post to this tab from the code via $Grav[‘debugger’]→addMessage($my_var).

Debugging & logging

In Timeline tab, you can view the breakdown of Grav timing.

Error Display

It displays the error messages regarding the block or page at a runtime. In Grav, you can easily identify the error and resolve the errors very quickly. Following are the error messages that will get displayed on your screen as shown in the following screenshot.

In the user/config/system.yaml file, you can disable the error page by setting it to false.

errors:
   display: false
   log: true

Logging

Logging is used for reporting errors and status information from libraries and application. In Grav, there are a few important logging features as specified below.

$Grav['log']->info('My informational message');
$Grav['log']->notice('My notice message');
$Grav['log']->debug('My debug message');
$Grav['log']->warning('My warning message');
$Grav['log']->error('My error message');
$Grav['log']->critical('My critical message');
$Grav['log']->alert('My alert message');
$Grav['log']->emergency('Emergency, emergency, there is an emergency here!');

All logging messages will get displayed in the Grav.log file which is present under the folder <your_folder_name>/logs/Grav.log

Next Topic:-Click Here

This Post Has One Comment

Leave a Reply