Prolog Mod

From TNG_Wiki
Jump to navigation Jump to search
Restricted Downloads of Prolog Mod are restricted to logged in users. If you do not have a user account on the TNG Wiki use the Request Account link to request a user account Restricted
Caution If you have trouble downloading with Google Chrome, Vivaldi, Brave or other Chromium based browser, try using a right-click and select Open in new Window, then F5, or use another browser such as Firefox


Caution


Prolog Mod
Summary Adds PHP Rotating Logs to TNG site
Validation
Mod Updated 24 Feb 2020
Download link
Download stats view statistics
Author(s) Rick Bisbee
Homepage Bisbee Family Connection
Mod Support Support for Prolog_Mod
Contact Developer As above
Latest Mod 12.2.0.2
Min TNG V 12
Max TNG V 12
Files modified
Related Mods
Notes



Prolog (PHP Rotating Log)

Prolog6.png

Prolog is a utility for TNG testers, mod developers and anyone who wants to monitor their websites for PHP or user issues. It is an extension of the Show PHP Errors mod created by Roger Mitchell (decd) and provides three selectable levels of error logging: 1) just errors; 2) all errors, warnings and deprecations except for notices (default); or 3) all errors, warnings, notices, and deprecated functions.

For TNG scripts, Prolog modifies subroot.php to add logging to any page that includes it. Scripts that work independently of TNG will not be logged by this mod; however, all errors continue to be logged in the server logs at the level set by PHP.

Having said that, if you do want to Prolog independent scripts, you can include prolog_conf.php at the top and as long as the mod remains installed, errors will be logged to the same rotating logs, at the same level as the others.

Prolog has two main files:

  1. prolog_conf.php creates the log files and manages the logging
  2. prolog.php displays and manages rotating logs from the Admin screen.

Prolog puts its daily PHP log files in a location provided by the user in the mod's Edit Options page. If the user has a PHP log file defined in php.ini, Prolog will override it. However, if the user sets the log file path in Prolog the same as in the php.ini, all logs will go to the same folder.

Features

Prolog adds a log access page link in the TNG Admin management area and features the following:

  • Rotating error logs created daily to prevent them becoming too large to manage;
  • Daily logs and error entries are timestamped in GMT;
  • A GMT clock is provided for admin perspective on timestamps;
  • Mod Edit Option to select error level for logging;
  • Mod Edit Option to set number of daily logs to keep before auto-deleting the oldest;
  • Daily logs selectable from drop down list for viewing and/or deletion (see visualization);
  • Logged items are listed from most recent to oldest for admin convenience;
  • Filter that limits viewing of logged errors to only items of interest;
  • Language support included in mod folder for easier maintenance;
  • A fatal shutdown handler.

Shutdown Handler

The shutdown handler is for errors that might not otherwise be logged because the system shuts down before processing them. Some, but not all servers are able to log fatal errors before shutting down, so there may be double entries in the logs -- but there will always be at least one if it occurs.

Fatal errors are very useful for revealing deliberate attacks that often result in displaying server information that attackers hope to exploit. While Prolog records them for the administrator, all the attacker sees is this, for example, after attempting to access a forbidden script:

[20-02-24 18:34:02] Something went wrong. Please report the error or come back later.

The exact time can be used to compare with the logs, should a legitimate user choose to report it. Compare the actual log entry for displayed message above:

[24-Feb-2020 18:34:02 GMT] Fatal error: File access violation in fgw/fgw_setup.php on line 26 

Language Support

The mod support folder includes support for Czech, English, French, German, Spanish and Swedish. You can modify the files right in the support folder to change the translations. You can add new folders with other languages if you like. If you make changes or additions I will be happy to add them to the distribution package for others to use as well. Just email them to me or use the mod support link on the Prolog_Mod TNGWiki page.

TNG Version Compatibility

Prolog is compatible with TNG version 12 and up.

Screen Shots

Prolog3.jpg

PHP Error Log link in the Admin page header menu. Note the daily log selected from the drop down list, and that the site's PHP version and current error reporting level are displayed in the prolog header bar. In the above example, All errors, notices, warnings and deprecations are being logged. A developer would want to show all errors and correct those thrown by their own mods or scripts, which can be isolated from any others by using the filter.

Prolog4.jpg

Installation

Prolog installs as a normal TNG mod. Download and unzip the contents -- one file and one folder. Place the prolog.cfg file and the support folder into your TNG site's mods directory. Do not remove folders and files from the support folder -- just leave them there. Navigate to your Mod Manager, find and open the mod listing and click on Install.

Configuration

Location for Daily Error Logs

This is very important. As soon as you've installed the mod, open it in the mod manager and click on Edit Options. There you must enter the server path to an existing directory for your daily logs. Be sure to terminate the path with a forward slash and do not surround it with quotes of any kind. Your server path can lead to a location above the public_html directory for extra security if you like (recommended.) If you fail to specify a log file path, or if the path does not exist, Prolog will show a message explaining the problem when the PHP Prolog link is clicked at the top of the TNG Admin page.

Setting the Error Level

  • Error level 1 will only log actual, usually fatal errors.
  • Error level 2, the default, should be about right for a live site. It will log errors, warnings and PHP function deprecations. That latter means the scripts will stop working with new PHP upgrades, so we should know about them.
  • Error level 3 logs everything -- errors, notices, warnings and deprecations. Because TNG emotes large numbers of notices right now, error level 3 should only be used while actually testing a script and reduced back to 1 or 2 when not testing. Even a daily log can get very large at error level 3.