aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/Utils.php
diff options
context:
space:
mode:
authorVirtualTam <virtualtam@flibidi.net>2016-01-17 20:11:42 +0100
committerVirtualTam <virtualtam@flibidi.net>2016-01-17 20:11:42 +0100
commit122d90ef8d83c6702a8b47f81c32fa3ba7a53c31 (patch)
tree6858a1d21267f504ddad6c40af616127cb4110b4 /application/Utils.php
parent73151d95469b6aee727f3c1f55c07bb91346f9d3 (diff)
parent478ce8afb467d59eb3dce5ec4a9e9446b134aecf (diff)
downloadShaarli-122d90ef8d83c6702a8b47f81c32fa3ba7a53c31.tar.gz
Shaarli-122d90ef8d83c6702a8b47f81c32fa3ba7a53c31.tar.zst
Shaarli-122d90ef8d83c6702a8b47f81c32fa3ba7a53c31.zip
Merge pull request #438 from virtualtam/utils/logm/date-format
Logging: improve formatting to enable fail2ban parsing
Diffstat (limited to 'application/Utils.php')
-rw-r--r--application/Utils.php9
1 files changed, 7 insertions, 2 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/**