-
-
Notifications
You must be signed in to change notification settings - Fork 188
/
AbstractBackend.php
77 lines (69 loc) · 1.98 KB
/
AbstractBackend.php
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
declare(strict_types=1);
namespace Neos\Flow\Log\Backend;
/*
* This file is part of the Neos.Flow package.
*
* (c) Contributors of the Neos Project - www.neos.io
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* source code.
*/
use Neos\Flow\Log\PlainTextFormatter;
/**
* An abstract Log backend
*
* @api
*/
abstract class AbstractBackend implements BackendInterface
{
/**
* One of the LOG_* constants. Anything below that will be filtered out.
* @var integer
*/
protected $severityThreshold = LOG_INFO;
/**
* Flag telling if the IP address of the current client (if available) should be logged.
* @var boolean
*/
protected $logIpAddress = false;
/**
* Constructs this log backend
*
* @param mixed $options Configuration options - depends on the actual backend
* @api
*/
public function __construct($options = [])
{
if (is_array($options) || $options instanceof \ArrayAccess) {
foreach ($options as $optionKey => $optionValue) {
$methodName = 'set' . ucfirst($optionKey);
if (method_exists($this, $methodName)) {
$this->$methodName($optionValue);
}
}
}
}
/**
* The maximum severity to log, anything less severe will not be logged.
*
* @param int $severityThreshold One of the LOG_* constants
* @return void
* @api
*/
public function setSeverityThreshold(int $severityThreshold): void
{
$this->severityThreshold = $severityThreshold;
}
/**
* Enables or disables logging of IP addresses.
*
* @param bool $logIpAddress Set to true to enable logging of IP address, or false to disable
* @return void
*/
public function setLogIpAddress(bool $logIpAddress): void
{
$this->logIpAddress = $logIpAddress;
}
}