Roundcube Community Forum

 

What is the proper method to print debug messages on a plugin

Started by ASeques, April 26, 2013, 11:16:54 AM

Previous topic - Next topic

ASeques

I am modifying autologon.php to achieve something else, and I'd like to add some debug messages to it. After looking across a lot of different plugins, I've couldn't find an 'official' way to enable debug in the plugins, could someone point me to a good example?

Regards

JohnDoh

i suppose it depends what you are trying to achive. a simple way is to have a debug option in your plugin's config and then use rcube::write_log() to write your debug info into a log file or you could use the debug_level from the main config file.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more...

ASeques

I was curious because there isn't a single plugin using the debug_level variable and using roundcube methods to do the logging.
I'll check it out...

SKaero

I'm not sure where you've looked but I know the password plugin uses the roundcube methods for logging.

ASeques

Yes, my bad, I was looking for the debug_level logic instead of the error_log functions. After the tip of JohnDoh i ended finding a solution.
Now I am using this:

  • console() -> for debug messages
  • error_log() -> for the errors

console() writes the messages to logs/console or to the web interface directly depending on debug_level, exactly what I needed.