-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPhpAppDataRetriever.php
More file actions
53 lines (46 loc) · 1.45 KB
/
PhpAppDataRetriever.php
File metadata and controls
53 lines (46 loc) · 1.45 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
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
namespace phpWTL;
use phpWTL\aBasicDataRetriever;
require_once 'aBasicDataRetriever.php';
/**
* Data retriever for PHP event/error/exception logging.
*
* @author Michael Beyer <mgbeyer@gmx.de>
* @version v0.1.0
* @api
*/
class PhpAppDataRetriever extends aBasicDataRetriever {
/**
* @param object $loggerContent Provide a LoggerContent object. The FieldDescriptor is derived from the LoggerContent object.
*
* @author Michael Beyer <mgbeyer@gmx.de>
* @version v0.1.1
*/
protected function __construct($loggerContent= null) {
static::$loggerContent= $loggerContent;
if (static::$loggerContent) static::$fieldDescriptor= $loggerContent->getFormatDescriptor();
}
/**
* Retrieve data for a single log field and store it in the associated LoggerContent object.
*
* @param string $field_name ID of log format field.
* @param string $value Provide an (optional) value to pass thru to the LoggerContent object, so allowing for the injection of external data.
*
* @author Michael Beyer <mgbeyer@gmx.de>
* @version v0.1.0
* @api
*/
public function retrieveField($field_name, $value= null) {
if (static::$fieldDescriptor && static::$loggerContent) {
if ($value==null) {
switch ($field_name) {
case "timestamp":
$value= time();
break;
}
if ($value!="") static::$loggerContent->__set($field_name, $value);
} else static::$loggerContent->__set($field_name, $value);
}
}
}
?>