Skip to content
Snippets Groups Projects
Commit eca260a3 authored by Jaime Perez Crespo's avatar Jaime Perez Crespo
Browse files

Reformat SimpleSAML_Logger_LoggingHandlerFile.

parent bfe70e3f
No related branches found
No related tags found
No related merge requests found
<?php <?php
/** /**
* A class for logging * A class for logging
* *
* @author Lasse Birnbaum Jensen, SDU. * @author Lasse Birnbaum Jensen, SDU.
* @author Andreas Åkre Solberg, UNINETT AS. <andreas.solberg@uninett.no> * @author Andreas Åkre Solberg, UNINETT AS. <andreas.solberg@uninett.no>
* @package SimpleSAMLphp * @package SimpleSAMLphp
* @version $ID$
*/ */
class SimpleSAML_Logger_LoggingHandlerFile implements SimpleSAML_Logger_LoggingHandler class SimpleSAML_Logger_LoggingHandlerFile implements SimpleSAML_Logger_LoggingHandler
{ {
...@@ -17,11 +16,11 @@ class SimpleSAML_Logger_LoggingHandlerFile implements SimpleSAML_Logger_LoggingH ...@@ -17,11 +16,11 @@ class SimpleSAML_Logger_LoggingHandlerFile implements SimpleSAML_Logger_LoggingH
* *
* @var null|string * @var null|string
*/ */
protected $logFile = NULL; protected $logFile = null;
/** /**
* This array contains the mappings from syslog loglevel to names. Copied * This array contains the mappings from syslog log levels to names. Copied more or less directly from
* more or less directly from SimpleSAML_Logger_LoggingHandlerErrorLog. * SimpleSAML_Logger_LoggingHandlerErrorLog.
*/ */
private static $levelNames = array( private static $levelNames = array(
SimpleSAML\Logger::EMERG => 'EMERGENCY', SimpleSAML\Logger::EMERG => 'EMERGENCY',
...@@ -33,7 +32,7 @@ class SimpleSAML_Logger_LoggingHandlerFile implements SimpleSAML_Logger_LoggingH ...@@ -33,7 +32,7 @@ class SimpleSAML_Logger_LoggingHandlerFile implements SimpleSAML_Logger_LoggingH
SimpleSAML\Logger::INFO => 'INFO', SimpleSAML\Logger::INFO => 'INFO',
SimpleSAML\Logger::DEBUG => 'DEBUG', SimpleSAML\Logger::DEBUG => 'DEBUG',
); );
private $processname = NULL; private $processname = null;
private $format; private $format;
...@@ -46,19 +45,19 @@ class SimpleSAML_Logger_LoggingHandlerFile implements SimpleSAML_Logger_LoggingH ...@@ -46,19 +45,19 @@ class SimpleSAML_Logger_LoggingHandlerFile implements SimpleSAML_Logger_LoggingH
assert($config instanceof SimpleSAML_Configuration); assert($config instanceof SimpleSAML_Configuration);
// get the metadata handler option from the configuration // get the metadata handler option from the configuration
$this->logFile = $config->getPathValue('loggingdir', 'log/') . $this->logFile = $config->getPathValue('loggingdir', 'log/').
$config->getString('logging.logfile', 'simplesamlphp.log'); $config->getString('logging.logfile', 'simplesamlphp.log');
$this->processname = $config->getString('logging.processname', 'SimpleSAMLphp'); $this->processname = $config->getString('logging.processname', 'SimpleSAMLphp');
if (@file_exists($this->logFile)) { if (@file_exists($this->logFile)) {
if (!@is_writeable($this->logFile)) { if (!@is_writeable($this->logFile)) {
throw new Exception("Could not write to logfile: " . $this->logFile); throw new Exception("Could not write to logfile: ".$this->logFile);
} }
} else { } else {
if (!@touch($this->logFile)) { if (!@touch($this->logFile)) {
throw new Exception( throw new Exception(
"Could not create logfile: " . $this->logFile . "Could not create logfile: ".$this->logFile.
" Loggingdir is not writeable for the webserver user." " The logging directory is not writable for the web server user."
); );
} }
} }
...@@ -81,12 +80,12 @@ class SimpleSAML_Logger_LoggingHandlerFile implements SimpleSAML_Logger_LoggingH ...@@ -81,12 +80,12 @@ class SimpleSAML_Logger_LoggingHandlerFile implements SimpleSAML_Logger_LoggingH
/** /**
* Log a message to the log file. * Log a message to the log file.
* *
* @param int $level The log level. * @param int $level The log level.
* @param string $string The formatted message to log. * @param string $string The formatted message to log.
*/ */
public function log($level, $string) public function log($level, $string)
{ {
if ($this->logFile != NULL) { if ($this->logFile != null) {
// set human-readable log level. Copied from SimpleSAML_Logger_LoggingHandlerErrorLog. // set human-readable log level. Copied from SimpleSAML_Logger_LoggingHandlerErrorLog.
$levelName = sprintf('UNKNOWN%d', $level); $levelName = sprintf('UNKNOWN%d', $level);
if (array_key_exists($level, self::$levelNames)) { if (array_key_exists($level, self::$levelNames)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment