Skip to content

Commit a233ab0

Browse files
committed
Merge pull request #23 from ziadoz/patch-1
Changed log writer behaviour so it only creates a log file when required...
2 parents 6f520a5 + 1e1fc57 commit a233ab0

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Log Writers/TimestampLogFileWriter.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,6 @@ public function __construct( $settings = array() ) {
8484

8585
//Remove trailing slash from log path
8686
$this->settings['path'] = rtrim($this->settings['path'], DIRECTORY_SEPARATOR);
87-
88-
//Open resource handle to log file
89-
$this->resource = fopen($this->settings['path'] . DIRECTORY_SEPARATOR . date($this->settings['name_format']), 'a');
9087
}
9188

9289
/**
@@ -125,6 +122,11 @@ public function write( $object, $level ) {
125122
(string)$object
126123
), $this->settings['message_format']);
127124

125+
//Open resource handle to log file
126+
if (! $this->resource) {
127+
$this->resource = fopen($this->settings['path'] . DIRECTORY_SEPARATOR . date($this->settings['name_format']), 'a');
128+
}
129+
128130
//Output to resource
129131
fwrite($this->resource, $message . PHP_EOL);
130132
}

0 commit comments

Comments
 (0)