Author Topic: What is the proper method to print debug messages on a plugin  (Read 6726 times)

Offline ASeques

  • Jr. Member
  • **
  • Posts: 12
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

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,855
Re: What is the proper method to print debug messages on a plugin
« Reply #1 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.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and moreā€¦

Offline ASeques

  • Jr. Member
  • **
  • Posts: 12
Re: What is the proper method to print debug messages on a plugin
« Reply #2 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...

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,879
    • SKaero - Custom Roundcube development
Re: What is the proper method to print debug messages on a plugin
« Reply #3 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.

Offline ASeques

  • Jr. Member
  • **
  • Posts: 12
Re: What is the proper method to print debug messages on a plugin
« Reply #4 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() -> 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.