Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 32 additions & 3 deletions src/app/code/community/Cloudinary/Cloudinary/Model/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,23 @@ class Cloudinary_Cloudinary_Model_Logger extends Mage_Core_Model_Abstract implem

public function warning($message, array $context = array())
{
Mage::log($message, Zend_Log::WARN);
if ($this->isActive()) {
Mage::log($message, Zend_Log::WARN, $this->getFilename());
}
}

public function notice($message, array $context = array())
{
Mage::log($message, Zend_Log::NOTICE);
if ($this->isActive()) {
Mage::log($message, Zend_Log::NOTICE, $this->getFilename());
}
}

public function error($message, array $context = array())
{
Mage::log($message, Zend_Log::ERR);
if ($this->isActive()) {
Mage::log($message, Zend_Log::ERR, $this->getFilename());
}
}

public function debugLog($message)
Expand Down Expand Up @@ -45,4 +51,27 @@ public static function getInstance()
{
return Mage::getModel('cloudinary_cloudinary/logger');
}

/**
* check is logging is enabled
* @return bool
*/
public function isActive()
{
return Mage::getStoreConfigFlag('cloudinary/log/actice');
}

/**
* return filename where to log data
* @return mixed|string
*/
public function getFilename()
{
$filename = Mage::getStoreConfig('cloudinary/log/filename');
if (empty($filename)) {
$filename = Mage::getStoreConfig('dev/log/file');
}

return $filename;
}
}
4 changes: 4 additions & 0 deletions src/app/code/community/Cloudinary/Cloudinary/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@
<configuration>
<cloudinary_cdn_subdomain>1</cloudinary_cdn_subdomain>
</configuration>
<log>
<active>1</active>
<filename>cloudinary.log</filename>
</log>
</cloudinary>
</default>
<crontab>
Expand Down
19 changes: 19 additions & 0 deletions src/app/code/community/Cloudinary/Cloudinary/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,25 @@
</cloudinary_image_dpr>
</fields>
</transformations>
<log>
<active>
<label>Enable Logging</label>
<frontend_type>select</frontend_type>
<sort_order>1</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<source_model>adminhtml/system_config_source_yesno</source_model>
</active>
<filename>
<label>Filename for Logging (default system.xml)</label>
<frontend_type>text</frontend_type>
<sort_order>1</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</filename>
</log>
</groups>
</cloudinary>
</sections>
Expand Down