Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
adds a new .ini entry to enable/disable the logger
Browse files Browse the repository at this point in the history
  • Loading branch information
shinobu authored and white-gecko committed Jul 10, 2017
1 parent 73f9c29 commit c00fcfd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
7 changes: 6 additions & 1 deletion application/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ public function _initConfig()
$config->libraryUrlBase = $config->staticUrlBase
. $config->libraries->path;

//check if log.level has a valid integer as value
if (!((int)$config->log->level >= 0 && (int)$config->log->level <= 7)) {
$config->log->level = 0;
}
// define constants for development/debugging
if (isset($config->debug) && (boolean)$config->debug) {
// display errors
Expand All @@ -208,6 +212,7 @@ public function _initConfig()
}

// log everything
$config->log->enabled = true;
$config->log->level = 7;
}

Expand Down Expand Up @@ -323,7 +328,7 @@ public function _initLogger()

// initialize logger
$writer = null;
if (is_writable($config->log->path) && ((boolean)$config->log->level !== false)) {
if (is_writable($config->log->path) && ((boolean)$config->log->enabled == true)) {
$levelFilter = new Zend_Log_Filter_Priority((int)$config->log->level, '<=');

$logName = $config->log->path . 'ontowiki';
Expand Down
2 changes: 1 addition & 1 deletion application/classes/OntoWiki.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ public function getCustomLogger($identifier = self::DEFAULT_LOG_IDENTIFIER)
}

// initialize logger
if (is_writable($config->log->path) && ((boolean)$config->log->level !== false)) {
if (is_writable($config->log->path) && ((boolean)$config->log->enabled == true)) {
$levelFilter = new Zend_Log_Filter_Priority((int)$config->log->level, '<=');

$writer = new Zend_Log_Writer_Stream($config->log->path . $identifier . '.log');
Expand Down
1 change: 1 addition & 0 deletions application/config/default.ini
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ service.auth.allowGet = false
; 6: Informational - Informational messages
; 7: Debug - Debug messages
;
log.enabled = true
log.level = 4
log.path = "logs"

Expand Down
3 changes: 2 additions & 1 deletion application/controllers/ApplicationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ public function aboutAction()
),
'Logging' => array(
'Path' => rtrim($this->_config->log->path, '/') . $logWritable,
'Level' => (bool)$this->_config->log->level ? $this->_config->log->level : 'disabled'
'Status' => (bool)$this->_config->log->enabled ? 'enabled' : 'disabled',
'Level' => (int)$this->_config->log->level
)
);

Expand Down

0 comments on commit c00fcfd

Please sign in to comment.