We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

How to log ...

Development and Programming

juro's avatar
juro
118 posts
17 years ago
juro's avatar juro

Hi, When developing anything I like to use logs for debuggin purposes. Is there anything that I can use in ExpressionEngine?

For example: It would really interest me to check the value of the $_POST variable.

       
juro's avatar
juro
118 posts
17 years ago
juro's avatar juro

For the lack of any ideas I have created the following work-around:

  1. Create a table exp_debug with two fields, deb_id and deb_data
  2. To log anything, add the following line: $DB->query(“INSERT INTO exp_debug SET deb_data=’log message’”);

Now look at the exp_debug and the message will be logged.

       
Derek Jones's avatar
Derek Jones
7,561 posts
17 years ago
Derek Jones's avatar Derek Jones

Depending on your needs, you may just wish to write debugging info to the Template Parsing Log (Output and Debugging Preferences) with $TMPL->log_item().

       
juro's avatar
juro
118 posts
17 years ago
juro's avatar juro

Well the problem is that if I am not using a template, that won’t work or am I not understanding it properly?

In my case I need some logging before EE actually edits or adds entries.

       
Derek Jones's avatar
Derek Jones
7,561 posts
17 years ago
Derek Jones's avatar Derek Jones

Yes, it would depends on what hook you are using as to whether or not writing to the Template Parsing log would be beneficial. I’m guessing you are using control panel extension from your last sentence, in which case you are correct, you’ll need to log information another way. You could still output to the screen if you’re debugging, incidentally, but for actual logging, you’d need to write to the database or to a file.

       
juro's avatar
juro
118 posts
17 years ago
juro's avatar juro

Thank you for your answers. I’ll definitely look into the Template parsing log.

Guessing here: To debug to screen I would have to modify the EE code, which I don’t want to do. Therefore logging to the database is the easiest I could think of. I added the information for reference for anyone else who could need it.

       
Derek Jones's avatar
Derek Jones
7,561 posts
17 years ago
Derek Jones's avatar Derek Jones

Why would you have to modify EE’s code? echo, print_r(), var_dump(), etc. are always at your disposal and valuable output methods for debugging, with the occasional exit($str); if you need the code to halt and display info.

       
Derek Jones's avatar
Derek Jones
7,561 posts
17 years ago
Derek Jones's avatar Derek Jones

Incidentally, I suppose you could use the log_action() method of the control panel Logger class (in the CP, accessed via the $LOG global object) and just write to the site’s control panel log, viewed in Admin > View Control Panel Log.

       
juro's avatar
juro
118 posts
17 years ago
juro's avatar juro

Ah, that looks more like it! It would be great to have that always displaying though as some kind of a console I guess. I’ll have to look into that - maybe I’ll write an extension of sorts. Thanx!

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.