Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

standardized & centralized message strings

  • Loading branch information...
commit 5ccf4f4717136fb5c0a8564b2c0485fd14ace3fe 1 parent 7feec00
Brian Fenton authored
Showing with 15 additions and 4 deletions.
  1. +15 −4 src/KLogger.php
View
19 src/KLogger.php
@@ -65,6 +65,17 @@ class KLogger
private $_fileHandle = null;
/**
+ * Standard messages produced by the class. Can be modified for il8n
+ * @var array
+ */
+ private $_messages = array(
+ //'writefail' => 'The file exists, but could not be opened for writing. Check that appropriate permissions have been set.',
+ 'writefail' => 'The file could not be written to. Check that appropriate permissions have been set.',
+ 'opensuccess' => 'The log file was opened successfully.',
+ 'openfail' => 'The file could not be opened. Check permissions.',
+ );
+
+ /**
* Default priority of log messages, if not specified
* @var integer
*/
@@ -145,17 +156,17 @@ public function __construct($logDirectory, $priority)
if (file_exists($this->_logFile)) {
if (!is_writable($this->_logFile)) {
$this->_logStatus = self::OPEN_FAILED;
- $this->_messageQueue[] = "The file exists, but could not be opened for writing. Check that appropriate permissions have been set.";
+ $this->_messageQueue[] = $this->_messages['writefail'];
return;
}
}
if (($this->_fileHandle = fopen($this->_logFile, "a"))) {
$this->_logStatus = self::LOG_OPEN;
- $this->_messageQueue[] = "The log file was opened successfully.";
+ $this->_messageQueue[] = $this->_messages['opensuccess'];
} else {
$this->_logStatus = self::OPEN_FAILED;
- $this->_messageQueue[] = "The file could not be opened. Check permissions.";
+ $this->_messageQueue[] = $this->_messages['openfail'];
}
}
@@ -249,7 +260,7 @@ public function writeFreeFormLine($line)
if ($this->_logStatus == self::LOG_OPEN
&& $this->_priority != self::OFF) {
if (fwrite($this->_fileHandle, $line) === false) {
- $this->_messageQueue[] = "The file could not be written to. Check that appropriate permissions have been set.";
+ $this->_messageQueue[] = $this->_messages['writefail'];
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.