-
Notifications
You must be signed in to change notification settings - Fork 87
Expand file tree
/
Copy pathcsrfpDefaultLogger.php
More file actions
40 lines (37 loc) · 1.19 KB
/
csrfpDefaultLogger.php
File metadata and controls
40 lines (37 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
/**
* This file has implementation for csrfpDefaultLogger class.
*/
include __DIR__ ."/LoggerInterface.php";
if (!defined('__CSRF_PROTECTOR_DEFAULT_LOGGER_')) {
// to avoid multiple declaration errors
define('__CSRF_PROTECTOR_DEFAULT_LOGGER_', true);
/**
* Default logger class for CSRF Protector.
*
* This implementation is based on PHP's default error_log implementation.
*/
class csrfpDefaultLogger implements LoggerInterface {
/**
* Sends error message to the defined error_handling routines.
*
* Based on PHP's default error_log method implementation.
*
* Parameters:
* $message - the log message
* $context - context array
*
* Return:
* void
*/
public function log($message, $context = array()) {
$context['timestamp'] = time();
$context['message'] = $message;
// Convert log array to JSON format to be logged
$contextString = "OWASP CSRF Protector PHP "
.json_encode($context)
.PHP_EOL;
error_log($contextString, /* message_type= */ 0);
}
}
}