Warning: Cannot modify header information - headers already sent by (output started at /www/wwwroot/sbboke.com/wp-content/plugins/wordpress-seo/src/integrations/front-end-integration.php:409) in /www/wwwroot/sbboke.com/wp-content/themes/pacify/content-single.php on line 5

自定义Magento模块日志

PHP错误和来自其他模块的消息会tail -f在调试时使您混乱,有时将单独的日志记录到主系统上很好。

使用以下命令设置您自己的日志适配器:

<?php

$my_log = Mage::getModel('core/log_adapter', 'my_module.log');

并注销!

<?php

$my_log->log($message);

将其包装在课堂上的额外要点:

<?php

class Nick_Module_Model_Log {
  protected $_adapter;

  public __construct() {
    $this->_adapter = Mage::getModel('core/log_adapter', 'my_module.log');
  }

  // It's public incase we want to use ->debug(), ->info(), and friends
  public function getAdapter() {
    return $this->_adapter;
  }

  public function log($message) {
    $this->getAdapter()->log($message);
  }
}

$my_log = Mage::getSingleton('nick/log');
$my_log->log("Logging away!");

相关文章

0 0 投票数
文章评分
订阅评论
提醒
0 评论
内联反馈
查看所有评论