Can a kind soul please help me to understand C5 debug logging
Permalink
Hi,
I'm kinda new to developing with C5 (though I am learning!) and was hoping that an experienced member could set me straight on logging for debugging purposes.
I am trying to extend an existing add-on and can not seem to get logging working as I though it would.
For example, if I add the line Log::addEntry('hello','debug'); to the add-ons view.php file within the the blocks directory i get 'hello' grouped under the type 'debug in the C5 logs, but, if I add the same line to one of the files in the add-ons /models directory i get nothing.
I have tried adding Loader::library('log'); to the top of the file I am trying to debug in /models just in case the library was not already available but i still get nothing.
The page athttp://www.concrete5.org/documentation/developers/system/logging/... seems to indicate that "You should not have to do anything to load the logging library".
Could someone please put me straight and explain if logging is available in any php file under the C5 install and if so what is the foolproof way of ensuring that the library is available in any given php file so that variable values can be printed to the C5 logs for debugging.
Thanks in advance for any assistance.
I'm kinda new to developing with C5 (though I am learning!) and was hoping that an experienced member could set me straight on logging for debugging purposes.
I am trying to extend an existing add-on and can not seem to get logging working as I though it would.
For example, if I add the line Log::addEntry('hello','debug'); to the add-ons view.php file within the the blocks directory i get 'hello' grouped under the type 'debug in the C5 logs, but, if I add the same line to one of the files in the add-ons /models directory i get nothing.
I have tried adding Loader::library('log'); to the top of the file I am trying to debug in /models just in case the library was not already available but i still get nothing.
The page athttp://www.concrete5.org/documentation/developers/system/logging/... seems to indicate that "You should not have to do anything to load the logging library".
Could someone please put me straight and explain if logging is available in any php file under the C5 install and if so what is the foolproof way of ensuring that the library is available in any given php file so that variable values can be printed to the C5 logs for debugging.
Thanks in advance for any assistance.
Just a thought... type 'Debug' into the Intelligent Search box and choose 'Debug settings' and make sure you have 'Show errors on page'. See if that helps.
Hi mhawke,
Thanks, but yes I do have that setting already.
Unless I am mistaken, there is not a php error of the kind that would report to the browser screen (ie syntax error etc) as the file I am working in was called in the background as part of an AJAX transaction. To assist in debugging, I would really like to be able to print out server variable values and check that server objects exist at code points in the file I'm in to make sure that the data moving around is as I would expect.
For example, I would like to be able to output the id of a user I have just created to C5 log immediately after the user is created.
But at the moment the call to add a log entry immediately following the creation of a new user fails silently, I can't even write a simple text string to the C5 log at that code point. I just do not understand how the C5 log works and if what I want it todo should work.
Given the above example, at the next line immediately after a new user is created, and given that I wrote the code to create the new user and I know where that is and know that it works (ie if I comment that part out no user is created and if I put it back a user is created and I can login in using the credentials provided when the new user was added) I would have assumed that a call to write to the log after the user is created would work. Even just to write "I'm here" or something simple.
But, it does not seem to, so I am quite stumped. I can see other forum posts about nothing being written to the C5 log when debugging/testing but none of those posts seem to address why and how to fix the issue.
Any help to better understand if there are limits or scope issues when logging for debugging under C5 and if possible exactly how logging can be setup to work within a php file that is located in a /packages/myPackage/models directory would be fantastic.
Unfortunately, the test site that I am working on is also in shared hosting environment and at the moment I can't get to the php.ini file or apache log. As a result I am also having trouble calling FirePHP from within C5. So I thought the C5 log may be a solution.
I'll keep chipping away! Any help to better understand is very appreciated!
Thanks, but yes I do have that setting already.
Unless I am mistaken, there is not a php error of the kind that would report to the browser screen (ie syntax error etc) as the file I am working in was called in the background as part of an AJAX transaction. To assist in debugging, I would really like to be able to print out server variable values and check that server objects exist at code points in the file I'm in to make sure that the data moving around is as I would expect.
For example, I would like to be able to output the id of a user I have just created to C5 log immediately after the user is created.
But at the moment the call to add a log entry immediately following the creation of a new user fails silently, I can't even write a simple text string to the C5 log at that code point. I just do not understand how the C5 log works and if what I want it todo should work.
Given the above example, at the next line immediately after a new user is created, and given that I wrote the code to create the new user and I know where that is and know that it works (ie if I comment that part out no user is created and if I put it back a user is created and I can login in using the credentials provided when the new user was added) I would have assumed that a call to write to the log after the user is created would work. Even just to write "I'm here" or something simple.
But, it does not seem to, so I am quite stumped. I can see other forum posts about nothing being written to the C5 log when debugging/testing but none of those posts seem to address why and how to fix the issue.
Any help to better understand if there are limits or scope issues when logging for debugging under C5 and if possible exactly how logging can be setup to work within a php file that is located in a /packages/myPackage/models directory would be fantastic.
Unfortunately, the test site that I am working on is also in shared hosting environment and at the moment I can't get to the php.ini file or apache log. As a result I am also having trouble calling FirePHP from within C5. So I thought the C5 log may be a solution.
I'll keep chipping away! Any help to better understand is very appreciated!
Some Howtos you may find of use:
I suspect you already know about the browser developer console, if not, the last section of this helps:
http://www.concrete5.org/documentation/how-tos/editors/getting-help...
http://www.concrete5.org/documentation/how-tos/developers/some-tric...
http://www.concrete5.org/documentation/how-tos/developers/concrete5...
The free addons referenced - quick param view and quick log view, may also be of help.
I suspect you already know about the browser developer console, if not, the last section of this helps:
http://www.concrete5.org/documentation/how-tos/editors/getting-help...
http://www.concrete5.org/documentation/how-tos/developers/some-tric...
http://www.concrete5.org/documentation/how-tos/developers/concrete5...
The free addons referenced - quick param view and quick log view, may also be of help.
Hi JohntheFish,
Thanks for the tips! I have also downloaded a few of your diagnostic plugins and will soon be downloading more ... :)
Common sense kicked in a few days back and I have reverse migrated my dev site out of a shared Dreamhost hosting environment onto my local machine. Sanity has returned and dev is moving along a lot faster now that i can write and read to server and php logs.
Thanks again!
Thanks for the tips! I have also downloaded a few of your diagnostic plugins and will soon be downloading more ... :)
Common sense kicked in a few days back and I have reverse migrated my dev site out of a shared Dreamhost hosting environment onto my local machine. Sanity has returned and dev is moving along a lot faster now that i can write and read to server and php logs.
Thanks again!
Hi,
I have decide to install MAMP and develop locally to solve logging and debugging issues.
Thanks to mhawke for helping out.
I have decide to install MAMP and develop locally to solve logging and debugging issues.
Thanks to mhawke for helping out.