FirePHPPlugin.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /*
  3. * StatusNet Plugin: 0.9
  4. * Plugin Name: FirePHP
  5. * Description: Sends StatusNet log output to FirePHP
  6. * Version: 0.1
  7. * Author: Craig Andrews <candrews@integralblue.com>
  8. * Author URI: http://candrews.integralblue.com/
  9. */
  10. /*
  11. * StatusNet - the distributed open-source microblogging tool
  12. * Copyright (C) 2009, StatusNet, Inc.
  13. *
  14. * This program is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU Affero General Public License as published by
  16. * the Free Software Foundation, either version 3 of the License, or
  17. * (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU Affero General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU Affero General Public License
  25. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  26. * @category Plugin
  27. * @package MinifyPlugin
  28. * @maintainer Craig Andrews <candrews@integralblue.com>
  29. * @author Craig Andrews <candrews@integralblue.com>
  30. * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
  31. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  32. * @link http://status.net/
  33. */
  34. if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
  35. // We bundle the FirePHP library...
  36. set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/extlib/FirePHP/lib');
  37. class FirePHPPlugin extends Plugin
  38. {
  39. private $firephp;
  40. function onInitializePlugin()
  41. {
  42. //Output buffering has to be enabled so FirePHP can send the HTTP headers it needs
  43. ob_start();
  44. require_once('FirePHPCore/FirePHP.class.php');
  45. $this->firephp = FirePHP::getInstance(true);
  46. }
  47. function onStartLog(&$priority, &$msg, &$filename)
  48. {
  49. static $firephp_priorities = array(FirePHP::ERROR, FirePHP::ERROR, FirePHP::ERROR, FirePHP::ERROR,
  50. FirePHP::WARN, FirePHP::LOG, FirePHP::LOG, FirePHP::INFO);
  51. $fp_priority = $firephp_priorities[$priority];
  52. $this->firephp->fb($msg, $fp_priority);
  53. }
  54. function onPluginVersion(&$versions)
  55. {
  56. $versions[] = array('name' => 'FirePHP',
  57. 'version' => GNUSOCIAL_VERSION,
  58. 'author' => 'Craig Andrews',
  59. 'homepage' => 'http://status.net/wiki/Plugin:FirePHP',
  60. 'rawdescription' =>
  61. // TRANS: Plugin description.
  62. _m('The FirePHP plugin writes StatusNet\'s log output to FirePHP.'));
  63. return true;
  64. }
  65. }