Roundcube Community Forum

Third Party Contributions => API Based Plugins => Topic started by: ASeques on April 26, 2013, 11:16:54 AM

Title: What is the proper method to print debug messages on a plugin
Post by: ASeques on April 26, 2013, 11:16:54 AM
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
Title: Re: What is the proper method to print debug messages on a plugin
Post by: JohnDoh on April 26, 2013, 12:38:51 PM
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.
Title: Re: What is the proper method to print debug messages on a plugin
Post by: ASeques on April 29, 2013, 07:00:37 AM
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...
Title: Re: What is the proper method to print debug messages on a plugin
Post by: SKaero on April 29, 2013, 02:15:07 PM
I'm not sure where you've looked but I know the password plugin uses the roundcube methods for logging.
Title: Re: What is the proper method to print debug messages on a plugin
Post by: ASeques on April 30, 2013, 04:13:35 AM
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() writes the messages to logs/console or to the web interface directly depending on debug_level, exactly what I needed.