aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--application/Utils.php9
-rw-r--r--tests/UtilsTest.php2
2 files changed, 8 insertions, 3 deletions
diff --git a/application/Utils.php b/application/Utils.php
index a9a10ece..cb30595f 100644
--- a/application/Utils.php
+++ b/application/Utils.php
@@ -6,14 +6,19 @@
6/** 6/**
7 * Logs a message to a text file 7 * Logs a message to a text file
8 * 8 *
9 * The log format is compatible with fail2ban.
10 *
9 * @param string $logFile where to write the logs 11 * @param string $logFile where to write the logs
10 * @param string $clientIp the client's remote IPv4/IPv6 address 12 * @param string $clientIp the client's remote IPv4/IPv6 address
11 * @param string $message the message to log 13 * @param string $message the message to log
12 */ 14 */
13function logm($logFile, $clientIp, $message) 15function logm($logFile, $clientIp, $message)
14{ 16{
15 $line = strval(date('Y/m/d_H:i:s')).' - '.$clientIp.' - '.strval($message).'\n'; 17 file_put_contents(
16 file_put_contents($logFile, $line, FILE_APPEND); 18 $logFile,
19 date('Y/m/d H:i:s').' - '.$clientIp.' - '.strval($message).'\n',
20 FILE_APPEND
21 );
17} 22}
18 23
19/** 24/**
diff --git a/tests/UtilsTest.php b/tests/UtilsTest.php
index 869a9695..f3bb556e 100644
--- a/tests/UtilsTest.php
+++ b/tests/UtilsTest.php
@@ -22,7 +22,7 @@ class UtilsTest extends PHPUnit_Framework_TestCase
22 protected static $testLogFile = 'tests.log'; 22 protected static $testLogFile = 'tests.log';
23 23
24 // Expected log date format 24 // Expected log date format
25 protected static $dateFormat = 'Y/m/d_H:i:s'; 25 protected static $dateFormat = 'Y/m/d H:i:s';
26 26
27 27
28 /** 28 /**