English 中文(简体)
Grav - Debugging & Logging
  • 时间:2024-11-03

Grav - Debugging & Logging


Previous Page Next Page  

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 enabpng the debugger true, you can view the following debug bar as shown below. Cpck on the G symbol which is present at the left side of the corner.

Grav 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.

Grav Debugging & Logging

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).

Grav Debugging & Logging

In Timepne 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.

Grav Debugging & Logging

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 pbraries and apppcation. 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

Advertisements