Zoph/Solving Problems/Logging in Zoph 0.8.1 and later

From Wikibooks, open books for an open world
Jump to: navigation, search

As of Zoph 0.8.1, the DEBUG configuration option has been replaced by 3 configuration options:

This will allow for much more granular debugging. Everyone who has tried using the DEBUG option in an earlier version of Zoph, has noticed that in some cases you get a lot of information that you do not require for the problem you are investigating and it's easy to overload yourself with debug information. Therefore, Zoph 0.8.1 introduces a new debugging mechanism that will give you much more control over which messages are displayed and which not.

Log Subjects[edit]

Each logging message has been categorized in a subject:

Message subjects
log::ALL All messages
log::VARS Messages regarding setting of variables
log::LANG Messages regarding the translation of Zoph
log::LOGIN Messages regarding the Login procedure
log::REDIRECT Messages regarding redirection
log::DB Messages regarding the database connection
log::SQL Messages regarding SQL Queries
log::XML Messages regarding XML creation
log::IMG Messages regarding image creation
log::IMPORT Messages regarding the import functions
log::GENERAL Other messages
log::NONE No messages.

Log Severity[edit]

and each message has gotten a severity indiction, that indicates how "bad" the situation is:

Severity indications
log::DEBUG Debugging messages, Zoph gives information about what it's doing.
log::NOTIFY Notification about something that is happening which is influencing Zoph's program flow
log::WARN Warning about something that is happening
log::ERROR Error condition, something has gone wrong, but Zoph can recover
log::FATAL Fatal error, something has gone wrong and Zoph needs to stop execution of the current script.
log::NONE Do not display any messages

Configuration[edit]

As mentioned before, 3 new configuration options have been added to config.inc.php.

LOG_ALWAYS[edit]

This setting configures a log level that is always displayed, no matter which subject the message is in. By default this is set to log::FATAL, which means that any message that has a severity of FATAL or worse is displayed. Since log::FATAL is the worst kind of message, only log::FATAL messages will be displayed. If you would set it to log::WARN, any message with a severity of WARN or worse will be displayed, hence any FATAL, ERROR or WARN message will be displayed. A special severity level has been added to surpress all messages: log::NONE

Examples[edit]

define('LOG_ALWAYS', log::ERROR);

All messages which indicate an error or a fatal error will be displayed.

define('LOG_ALWAYS', log::NOTIFY);

All messages, except debug-level messages will be displayed.

define('LOG_ALWAYS', log::DEBUG);

All messages will be displayed.

LOG_SEVERITY[edit]

This setting works in the same way as the previous one, except that only messages for a specific subject will be displayed; it is used in combination with LOG_SUBJECT to achieve this.

Examples[edit]

define('LOG_SEVERITY', log::ERROR);
define('LOG_SUBJECT', log::LANG);

All messages which indicate an error or a fatal error, regarding the translation of Zoph will be displayed.

define('LOG_SEVERITY', log::NOTIFY);
define('LOG_SUBJECT', log::DB);

All messages, except debug-level messages, regarding the database connection will be displayed.

define('LOG_SEVERITY', log::DEBUG);
define('LOG_SUBJECT', log::SQL);

All messages regarding SQL-queries will be displayed. (since the SQL queries themselves are considered debug information, you will need this setting to show them.)

LOG_SUBJECT[edit]

With this setting you can control for which subjects you want to see the messages. There is a special subject to show all messages: log::ALL.

You can also combine multiple subjects, using the | (or) sign and the ~ (not) sign.

Examples[edit]

define('LOG_SEVERITY', log::ERROR);
define('LOG_SUBJECT', log::LANG | log::IMG);

All messages which indicate an error or a fatal error, regarding the translation of Zoph or images will be displayed.

define('LOG_SEVERITY', log::NOTIFY);
define('LOG_SUBJECT', log::ALL | ~log::SQL);

All messages, except debug-level messages, except those regarding SQL queries are displayed.

define('LOG_SEVERITY', log::DEBUG);
define('LOG_SUBJECT', log::ALL ~(log::REDIRECT | log::DB));

All messages except those regarding redirects or the database connection will be displayed.