diff options
-rw-r--r-- | README.markdown | 5 | ||||
-rwxr-xr-x | src/Logger.php | 14 |
2 files changed, 14 insertions, 5 deletions
diff --git a/README.markdown b/README.markdown index 00dfce4..3acf7cd 100644 --- a/README.markdown +++ b/README.markdown @@ -130,10 +130,11 @@ Here's the full list: | Option | Default | Description | | ------ | ------- | ----------- | -| extension | 'txt' | The log file extension | -| prefix | 'log_' | The log file prefix | | dateFormat | 'Y-m-d G:i:s.u' | The format of the date in the start of the log lone (php formatted) | +| extension | 'txt' | The log file extension | +| filename | [prefix][date].[extension] | Set the filename for the log file. **This overrides the prefix and extention options.** | | flushFrequency | `false` (disabled) | How many lines to flush the output buffer after | +| prefix | 'log_' | The log file prefix | ## Why use KLogger? diff --git a/src/Logger.php b/src/Logger.php index a563724..c56bfaf 100755 --- a/src/Logger.php +++ b/src/Logger.php @@ -38,10 +38,11 @@ class Logger extends AbstractLogger * @var array
*/
private $options = array (
- 'prefix' => 'log_',
'extension' => 'txt',
'dateFormat' => 'Y-m-d G:i:s.u',
- 'flushFrequency' => false
+ 'filename' => false,
+ 'flushFrequency' => false,
+ 'prefix' => 'log_'
);
/**
@@ -115,7 +116,14 @@ class Logger extends AbstractLogger mkdir($logDirectory, $this->defaultPermissions, true);
}
- $this->logFilePath = $logDirectory.DIRECTORY_SEPARATOR.$this->options['prefix'].date('Y-m-d').'.'.$this->options['extension'];
+ // Check for a set filename. In that case ignore prefix and extension
+ if ($this->options['filename']) {
+ $this->logFilePath = $logDirectory.DIRECTORY_SEPARATOR.$this->options['filename'];
+ } else {
+ $this->logFilePath = $logDirectory.DIRECTORY_SEPARATOR.$this->options['prefix'].date('Y-m-d').'.'.$this->options['extension'];
+ }
+
+
if (file_exists($this->logFilePath) && !is_writable($this->logFilePath)) {
throw new RuntimeException('The file could not be written to. Check that appropriate permissions have been set.');
}
|