In a previous post for Zurmo CRM administrators and evaluators (a.k.a. ‘Looking for Log in All the Wrong Places’*.) We learned about the location and types of log files and how to access both the Zurmo and Apache logs from your Arvixe personal hosting account.
This post is all about how you can get enhanced debug information in the Zurmo application log file. It’s one of those hidden features that you didn’t know you were missing until you really need it. Fortunately, the good folks at Zurmo gave us another spoonful of open source goodness. The Debug logging feature is so easy to use, it actually took me a few tries to get it right. If you have some PHP programming background, at some point, you are likely to be tempted sprinkle your code with ‘echo’ statements,; so you can get some console output when running a debugger might be overkill. If you regularly use Yii, you might consider using the Yii::log() static function. Those coming from a Java background might gravitate toward System.out.println(). Enough said. You get the idea…
So if you want to see more verbose debug info in your logs without littering your code, in typical Zurmo fashion, all you need to do is change some variables in a configuration file. Which file? , you ask.
Log in to your Arvixe personal hosting account with your favorite terminal emulator. – as described in a previous post**. Then change to the Zurmo configuration directory.
You will see a bunch of files, all of which we will be reviewing in upcoming articles. For now, you’ll want to focus on debug.php
At this point, you will need to fire up your favorite linux editor, or download the debug.php file so you can follow along. I use vi, so to open the file, type:
You can use the up, down and sideways arrows to move around the file, or for the hard-core, the vi keyboard shortcuts. We can learn more about vi later, let’s take a look at some of the logging options available to us:
First up… $debugOn.
// Keep this on ALL THE TIME WHEN DEVELOPING. Turn it off in production. // Check it in as false! $debugOn = false;
to change the value, in vi editor, move your cursor to the ‘f’ in the word ‘false’ and type ‘c’+’w’ ( change word) , then type ‘true’ and hit the ‘esc’ key. That’s the general process for changing words in vi, so we won’t repeat it.
When you change the value of $debugOn to ‘true’ from ‘false’ you will get a wealth of detailed information in your log file. However; everything comes with a price. The tradeoff here is going to be a noticeable slowing of performance of your application, as Zurmo will write out to disk more frequently than otherwise.
But first you need to save the file, and if you are following along in vi, simply type:
‘:’ + ‘w’ + ‘q’ +’!’ to save and exit the editor in one shot.
As a good shared hosting citizen, you’ll want to ensure that you reset the $debugOn flag, and any other debug options back to production mode when you are done troubleshooting your app. After all, you wouldn’t want your neighbor to leave his applications running continuously in debug mode either, right?
As a reminder, if you are using an Arvixe personal hosting plan, the Zurmo log location is: www/zurmo/app/protected/runtime/application.log
And of course, you will not be surprised to notice that your logs will grow much faster when you have debugging flags set, so that’s a more selfish reason to make sure that you remember to reset the debug.php options back to production mode, when not actively troubleshooting.
“But what if I need to do some extended troubleshooting, or I need to run profiling or benchmark tests?” Not to worry. In a future article, we’ll explain how to setup and configure an IDE (Integrated Development Environment) with a local webserver on your desktop so that you can perform much more sophisticated debugging, testing and troubleshooting as well as manage your code securely, seamlessly, and simply!
For reference, and for the curious, here are some of the other flags you can set in debug.php,
// Turn this on to use the application with the database unfrozen // Turn it off in production. // Check it in as true! $forceNoFreeze = false; // Turn this on to see additional performance information. // Turn it off in production. // Check it in as true! $performanceOn = false; // Turn this on to see RedBean queries. //Turn it off in production. // Check it in as false! $redBeanDebugOn = false; // Turn this on to save RedBean queries into file. // Turn it off in production. // Check it in as false! $redBeanDebugLogToFileOn = false; // Turn this on to see extra query data such as total count, // duplicate count, and duplicate queries // Check it in as false! $queryDataOn = false; // Turn this off to use php to do permissions, // rights, and polices. // Use this to comparatively test the mysql stored functions // and procedures. // Check it in as true! $securityOptimized = false; // Turn this off to use AuditEvent to do write audit entries when // the database is frozen. // When it is not frozen it will always be used. // Use this to comparatively test. // Check it in as true! $auditingOptimized = true;
** Alternatively you can use FTP or your IDE to access the Zurmo files. – We’ll cover how to configure both in upcoming articles.
(c) 2013 Windsor Wallaby. All rights reserved.