Skip to content

Commit 08c0c5d

Browse files
committed
Also log the format of the log entry (text/JSON).
1 parent 14e59e2 commit 08c0c5d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

test/log.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919
$type = $_REQUEST['type'];
2020
}
2121

22+
// Accept different formats of message; for now, that's plain-text and JSON.
23+
$formats = array('text', 'json');
24+
$format = 'text';
25+
if ( !empty($_REQUEST['format']) && in_array($_REQUEST['format'], $formats) ) {
26+
$format = $_REQUEST['format'];
27+
}
28+
2229
// Initially, assume that this client hasn't logged anything in the last minute.
2330
$has_accessed = false;
2431

@@ -89,6 +96,7 @@ function($access) {
8996
'time' => date('Y-m-d H:i:s'),
9097
'message' => $message,
9198
'type' => $type,
99+
'format' => $format,
92100
'hash' => sha1("$type:$message")
93101
);
94102

0 commit comments

Comments
 (0)