|
13 | 13 |
|
14 | 14 | namespace CodeIgniter\Test\Mock; |
15 | 15 |
|
| 16 | +use CodeIgniter\Log\Handlers\HandlerInterface; |
| 17 | +use Config\Logger; |
16 | 18 | use Tests\Support\Log\Handlers\TestHandler; |
17 | 19 |
|
18 | | -class MockLogger |
| 20 | +class MockLogger extends Logger |
19 | 21 | { |
20 | | - /* |
21 | | - |-------------------------------------------------------------------------- |
22 | | - | Error Logging Threshold |
23 | | - |-------------------------------------------------------------------------- |
24 | | - | |
25 | | - | You can enable error logging by setting a threshold over zero. The |
26 | | - | threshold determines what gets logged. Any values below or equal to the |
27 | | - | threshold will be logged. Threshold options are: |
28 | | - | |
29 | | - | 0 = Disables logging, Error logging TURNED OFF |
30 | | - | 1 = Emergency Messages - System is unusable |
31 | | - | 2 = Alert Messages - Action Must Be Taken Immediately |
32 | | - | 3 = Critical Messages - Application component unavailable, unexpected exception. |
33 | | - | 4 = Runtime Errors - Don't need immediate action, but should be monitored. |
34 | | - | 5 = Warnings - Exceptional occurrences that are not errors. |
35 | | - | 6 = Notices - Normal but significant events. |
36 | | - | 7 = Info - Interesting events, like user logging in, etc. |
37 | | - | 8 = Debug - Detailed debug information. |
38 | | - | 9 = All Messages |
39 | | - | |
40 | | - | You can also pass an array with threshold levels to show individual error types |
41 | | - | |
42 | | - | array(1, 2, 3, 8) = Emergency, Alert, Critical, and Debug messages |
43 | | - | |
44 | | - | For a live site you'll usually enable Critical or higher (3) to be logged otherwise |
45 | | - | your log files will fill up very fast. |
46 | | - | |
| 22 | + /** |
| 23 | + *-------------------------------------------------------------------------- |
| 24 | + * Error Logging Threshold |
| 25 | + *-------------------------------------------------------------------------- |
| 26 | + * |
| 27 | + * You can enable error logging by setting a threshold over zero. The |
| 28 | + * threshold determines what gets logged. Any values below or equal to the |
| 29 | + * threshold will be logged. Threshold options are: |
| 30 | + * |
| 31 | + * 0 = Disables logging, Error logging TURNED OFF |
| 32 | + * 1 = Emergency Messages - System is unusable |
| 33 | + * 2 = Alert Messages - Action Must Be Taken Immediately |
| 34 | + * 3 = Critical Messages - Application component unavailable, unexpected exception. |
| 35 | + * 4 = Runtime Errors - Don't need immediate action, but should be monitored. |
| 36 | + * 5 = Warnings - Exceptional occurrences that are not errors. |
| 37 | + * 6 = Notices - Normal but significant events. |
| 38 | + * 7 = Info - Interesting events, like user logging in, etc. |
| 39 | + * 8 = Debug - Detailed debug information. |
| 40 | + * 9 = All Messages |
| 41 | + * |
| 42 | + * You can also pass an array with threshold levels to show individual error types |
| 43 | + * |
| 44 | + * array(1, 2, 3, 8) = Emergency, Alert, Critical, and Debug messages |
| 45 | + * |
| 46 | + * For a live site you'll usually enable Critical or higher (3) to be logged otherwise |
| 47 | + * your log files will fill up very fast. |
| 48 | + * |
| 49 | + * @var int|list<int> |
47 | 50 | */ |
48 | | - |
49 | 51 | public $threshold = 9; |
50 | 52 |
|
51 | | - /* |
52 | | - |-------------------------------------------------------------------------- |
53 | | - | Date Format for Logs |
54 | | - |-------------------------------------------------------------------------- |
55 | | - | |
56 | | - | Each item that is logged has an associated date. You can use PHP date |
57 | | - | codes to set your own date formatting |
58 | | - | |
| 53 | + /** |
| 54 | + *-------------------------------------------------------------------------- |
| 55 | + * Date Format for Logs |
| 56 | + *-------------------------------------------------------------------------- |
| 57 | + * |
| 58 | + * Each item that is logged has an associated date. You can use PHP date |
| 59 | + * codes to set your own date formatting |
59 | 60 | */ |
60 | | - public $dateFormat = 'Y-m-d'; |
| 61 | + public string $dateFormat = 'Y-m-d'; |
61 | 62 |
|
62 | | - /* |
63 | | - |-------------------------------------------------------------------------- |
64 | | - | Log Handlers |
65 | | - |-------------------------------------------------------------------------- |
66 | | - | |
67 | | - | The logging system supports multiple actions to be taken when something |
68 | | - | is logged. This is done by allowing for multiple Handlers, special classes |
69 | | - | designed to write the log to their chosen destinations, whether that is |
70 | | - | a file on the server, a cloud-based service, or even taking actions such |
71 | | - | as emailing the dev team. |
72 | | - | |
73 | | - | Each handler is defined by the class name used for that handler, and it |
74 | | - | MUST implement the CodeIgniter\Log\Handlers\HandlerInterface interface. |
75 | | - | |
76 | | - | The value of each key is an array of configuration items that are sent |
77 | | - | to the constructor of each handler. The only required configuration item |
78 | | - | is the 'handles' element, which must be an array of integer log levels. |
79 | | - | This is most easily handled by using the constants defined in the |
80 | | - | Psr\Log\LogLevel class. |
81 | | - | |
82 | | - | Handlers are executed in the order defined in this array, starting with |
83 | | - | the handler on top and continuing down. |
84 | | - | |
| 63 | + /** |
| 64 | + *-------------------------------------------------------------------------- |
| 65 | + * Log Handlers |
| 66 | + *-------------------------------------------------------------------------- |
| 67 | + * |
| 68 | + * The logging system supports multiple actions to be taken when something |
| 69 | + * is logged. This is done by allowing for multiple Handlers, special classes |
| 70 | + * designed to write the log to their chosen destinations, whether that is |
| 71 | + * a file on the server, a cloud-based service, or even taking actions such |
| 72 | + * as emailing the dev team. |
| 73 | + * |
| 74 | + * Each handler is defined by the class name used for that handler, and it |
| 75 | + * MUST implement the CodeIgniter\Log\Handlers\HandlerInterface interface. |
| 76 | + * |
| 77 | + * The value of each key is an array of configuration items that are sent |
| 78 | + * to the constructor of each handler. The only required configuration item |
| 79 | + * is the 'handles' element, which must be an array of integer log levels. |
| 80 | + * This is most easily handled by using the constants defined in the |
| 81 | + * Psr\Log\LogLevel class. |
| 82 | + * |
| 83 | + * Handlers are executed in the order defined in this array, starting with |
| 84 | + * the handler on top and continuing down. |
| 85 | + * |
| 86 | + * @var array<class-string<HandlerInterface>, array<string, int|list<string>|string>> |
85 | 87 | */ |
86 | | - public $handlers = [ |
| 88 | + public array $handlers = [ |
87 | 89 | // File Handler |
88 | 90 | TestHandler::class => [ |
89 | 91 | // The log levels that this handler will handle. |
|
0 commit comments