Skip to content

Commit 4af1608

Browse files
author
Christoph Singer
committedMar 6, 2015
Merge pull request #2 from fdisotto/master
Added LOCK_EX to prevent anyone writing to the file at the same time
2 parents 72d37d4 + 6b4a598 commit 4af1608

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
 

‎Wa72/SimpleLogger/FileLogger.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* This class is a simple file logger implementing \Psr\Log\LoggerInterface (PSR-3)
44
*
5-
*
5+
*
66
* @author Christoph Singer
77
* @license MIT
88
*/
@@ -27,12 +27,12 @@ public function __construct($logfile)
2727
public function log($level, $message, array $context = array())
2828
{
2929
$logline = '[' . date('Y-m-d H:i:s') . '] ' . strtoupper($level) . ': ' . $this->interpolate($message, $context) . "\n";
30-
file_put_contents($this->logfile, $logline, FILE_APPEND);
30+
file_put_contents($this->logfile, $logline, FILE_APPEND | LOCK_EX);
3131
}
3232

3333
/**
3434
* Interpolates context values into the message placeholders.
35-
*
35+
*
3636
* This function is just copied from the example in the PSR-3 spec
3737
*
3838
*/

0 commit comments

Comments
 (0)
Failed to load comments.