Just another WordPress.com weblog

Wrapping it up in a class:

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);
  }

}
Set up your own log adapter with:
$my_log = Mage::getModel('core/log_adapter', 'my_module.log');

and log away!

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

Thanks,

Vatsal Patadia

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: