-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLog.php
62 lines (51 loc) · 1.45 KB
/
Log.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
<?php
/**
* @file Log.php
* @author Gabriele Tozzi <[email protected]>
* @package DoPhp
* @brief Logging-related classes
*/
namespace dophp\log;
/**
* Basic interface for a DoPhp logger
*/
interface Logger {
/**
* Constructs the logger
*
* @param $start int: DoPhp execution start microtime()
* @param $config array: DoPhp configuration array
* @param $db \dophp\Db: Database instance
* @param $auth \dophp\Auth: Auth instance
*/
public function __construct(int $start, array $config, \dophp\Db $db=null, \dophp\AuthInterface $user=null);
/**
* Called before the page is loaded
*
* @param $found bool: Whether the page include file has been found
* @param $name string: Name of the page
* @param $path string: The relative path inside this page
* @return Should return log entry id
*/
public function logPageRequest(bool $found, string $name, string $path=null);
}
/**
* Base class for a logger
*/
abstract class BaseLogger implements logger {
/** DoPhp start microtime */
protected $_start;
/** DoPhp config array */
protected $_conf;
/** Database instance */
protected $_db;
/** Auth instance */
protected $_user;
public function __construct(int $start, array $config, \dophp\Db $db=null, \dophp\AuthInterface $user=null) {
$this->_start = $start;
$this->_conf = $config;
$this->_db = $db;
$this->_user = $user;
}
abstract public function logPageRequest(bool $found, string $name, string $path=null);
}