Skip to content

Commit

Permalink
Make it possible to set logLevel
Browse files Browse the repository at this point in the history
  • Loading branch information
bramstroker committed Jul 3, 2017
1 parent 97846e8 commit 325ccc7
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
25 changes: 25 additions & 0 deletions app/code/community/Jowens/JobQueue/Model/Source/LogLevel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
if(file_exists(Mage::getBaseDir('lib').DS.'DJJob')){
set_include_path(get_include_path().PS.Mage::getBaseDir('lib').DS.'DJJob');
require_once('DJJob.php');
}
else if(!class_exists('\DJJob')){
Mage::throwException('The class DJJob does not exist. Please add the class to /lib/DJJob/DJJob.php OR install DJJob via magento-composer-installer. See https://github.com/jkowens/magento-jobqueue for more details.');
}

class Jowens_JobQueue_Model_Source_LogLevel
{
/**
* @return array
*/
public function toOptionArray()
{
return [
DJBase::DEBUG => 'DEBUG',
DJBase::INFO => 'INFO',
DJBase::WARN => 'WARN',
DJBase::ERROR => 'ERROR',
DJBase::CRITICAL => 'CRITICAL'
];
}
}
3 changes: 3 additions & 0 deletions app/code/community/Jowens/JobQueue/Model/Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,8 @@ protected function setupDJJob() {
if(!empty($config->initStatements)) {
DJJob::runQuery($config->initStatements);
}

$logLevel = (int) Mage::getStoreConfig('jobqueue/config/log_level');
DJBase::setLogLevel($logLevel);
}
}
1 change: 1 addition & 0 deletions app/code/community/Jowens/JobQueue/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
<cron_expr>*/5 * * * *</cron_expr>
<max_attempts>10</max_attempts>
<queue>default</queue>
<log_level>0</log_level>
</config>
</jobqueue>
</default>
Expand Down
10 changes: 9 additions & 1 deletion app/code/community/Jowens/JobQueue/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,15 @@
<frontend_type>text</frontend_type>
<sort_order>60</sort_order>
<show_in_default>1</show_in_default>
</queue>
</queue>
<log_level>
<label>Log Level</label>
<frontend_type>select</frontend_type>
<source_model>jobqueue/source_logLevel</source_model>
<sort_order>70</sort_order>
<comment>Minimal loglevel for logging to occur</comment>
<show_in_default>1</show_in_default>
</log_level>
</fields>
</config>
</groups>
Expand Down

0 comments on commit 325ccc7

Please sign in to comment.