This article highlights a MODX Extra by Sergey Shlokov. Sergey's extra delivers a neat improvement on the MODX Error Log. It's called controlErrorLog, and it works in MODX 3.
Error Log Annoyances
It's always bothered me that when you first want to look at the Error Log in MODX Revolution, you have to go to Manage -> Reports -> Error Log. It's easy to miss a section with the mouse and have to start over, and when you finally get to the Error Log, it may have nothing in it, or the errors may be quite stale and have nothing to do with what you're working on at the moment.
Even worse is the condition where, without your knowledge, errors have been piling up for a long time and the Error Log is now too big to display. Being offered the option to download it isn't really very satisfying at that point.
It's also a pain to have the Error Log take you away from where you were working, especially when you have to go back and forth to it often. You can open the Error Log in a separate browser tab by right-clicking on it and selecting "Open in new Window," but that adds an extra couple of steps. Then, you have to go back and forth between the browser tabs. I've been using this feature for a long time and I still forget to go back to the previous tab, which means going through the steps all over again to get back to the log.
Enter Sergey's Plugin
The plugin is attached to one System Event: OnManagerPageBeforeRender. It puts a little icon near your Gravatar in the Manager's Main Menu. If the Error Log is empty, you'll see a checkmark on a white background. If the Error Log has content, you'll see an exclamation point in a yellow triangle. Now you can see at a glance whether the Error Log has anything to show you. The icon is not updated until you change to a new Manager Page, or 60 seconds passes, but at least you won't have error messages piling up over long periods of time without being warned. By default, the icon is refreshed every 60 seconds, but you can change that in the System Settings for the extra (see below).
Better yet, when you click on the icon — the Error Log opens in a window! No goofing around with the submenus and mouse placement. You click on the icon, you're looking at the Error Log. When you close the log, you're right where you were before clicking on the icon.
If you haven't changed Manager Pages since an error occurred, or are working in the front end. The errors may not show, but all you have to do is click on the "Refresh" button in the log display to see the current state of the Error Log. You also have the option to clear the log or close the window without clearing it. You can still look at the error log the old-fashioned way if you want to.
Error Log Too Big?
Another great feature of Sergey's plugin is how it handles an oversized Error Log. Rather than just telling you that you're out of luck and offering to let you download the log, it will show you the 15 most recent entries! The odds are that what you need to see will be there, and if not, you can still download or clear the log. If you'd like to see more than 15 lines, you can change the controlerrorlog.last_line System Setting. Go to System (gear icon) -> System Settings and in the "Namespace" dropdown, select "controlerrorlog."
While you're there, look at the other settings and see if you'd like to change any of them. For example, if you're doing some intensive work, you may want to change the log's refresh rate to something shorter than 60 seconds.
Installing Sergey's Plugin
Go to Package Management ("Extras -> Installer" in MODX 2.3.5) and click on the "Download Extras" button. That will take you to the MODX repo where you can enter controlErrorLog in the search box and press Enter. Click on the "Download" button next to controlErrorLog. When the download is finished, click on the "Back to Package Management" button.
You should see the package in the grid. Click on its "Install" button. The plugin will be enabled on installation, and you should see the icon In the Manager's main menu as soon as you reload the Manager page. The icon will be a check mark if the error log is empty, and a yellow triangle if not.
Final Words
As I said above, the status of the Error Log with the plugin is not always up to date. It depends on what you've been doing. If all your work is in the front end, and you haven't changed views in the Manager, you may need to click on the icon and then on the "Refresh" button to see the current state. It's a slight inconvenience, but so much better than having to navigate to the Error Log the old way.
If there are new errors in a previously empty Error Log. You'll see the yellow exclamation point in the Manager's main menu as soon as you change locations in the Manager. No more having error messages pile up for days or weeks without your knowing about them.
Bob Ray is the author of the MODX: The Official Guide and dozens of MODX Extras including QuickEmail, NewsPublisher, SiteCheck, GoRevo, Personalize, EZfaq, MyComponent and many more. His website is Bob’s Guides. It not only includes a plethora of MODX tutorials but there are some really great bread recipes there, as well.