5
use CodeIgniter\Config\BaseConfig;
6
use CodeIgniter\Log\Handlers\FileHandler;
8
class Logger extends BaseConfig
11
* --------------------------------------------------------------------------
12
* Error Logging Threshold
13
* --------------------------------------------------------------------------
15
* You can enable error logging by setting a threshold over zero. The
16
* threshold determines what gets logged. Any values below or equal to the
17
* threshold will be logged.
19
* Threshold options are:
21
* - 0 = Disables logging, Error logging TURNED OFF
22
* - 1 = Emergency Messages - System is unusable
23
* - 2 = Alert Messages - Action Must Be Taken Immediately
24
* - 3 = Critical Messages - Application component unavailable, unexpected exception.
25
* - 4 = Runtime Errors - Don't need immediate action, but should be monitored.
26
* - 5 = Warnings - Exceptional occurrences that are not errors.
27
* - 6 = Notices - Normal but significant events.
28
* - 7 = Info - Interesting events, like user logging in, etc.
29
* - 8 = Debug - Detailed debug information.
32
* You can also pass an array with threshold levels to show individual error types
34
* array(1, 2, 3, 8) = Emergency, Alert, Critical, and Debug messages
36
* For a live site you'll usually enable Critical or higher (3) to be logged otherwise
37
* your log files will fill up very fast.
41
public $threshold = (ENVIRONMENT === 'production') ? 4 : 9;
44
* --------------------------------------------------------------------------
45
* Date Format for Logs
46
* --------------------------------------------------------------------------
48
* Each item that is logged has an associated date. You can use PHP date
49
* codes to set your own date formatting
51
public string $dateFormat = 'Y-m-d H:i:s';
54
* --------------------------------------------------------------------------
56
* --------------------------------------------------------------------------
58
* The logging system supports multiple actions to be taken when something
59
* is logged. This is done by allowing for multiple Handlers, special classes
60
* designed to write the log to their chosen destinations, whether that is
61
* a file on the getServer, a cloud-based service, or even taking actions such
62
* as emailing the dev team.
64
* Each handler is defined by the class name used for that handler, and it
65
* MUST implement the `CodeIgniter\Log\Handlers\HandlerInterface` interface.
67
* The value of each key is an array of configuration items that are sent
68
* to the constructor of each handler. The only required configuration item
69
* is the 'handles' element, which must be an array of integer log levels.
70
* This is most easily handled by using the constants defined in the
71
* `Psr\Log\LogLevel` class.
73
* Handlers are executed in the order defined in this array, starting with
74
* the handler on top and continuing down.
76
* @var array<class-string, array<string, int|list<string>|string>>
78
public array $handlers = [
80
* --------------------------------------------------------------------
82
* --------------------------------------------------------------------
84
FileHandler::class => [
85
// The log levels that this handler will handle.
98
* The default filename extension for log files.
99
* An extension of 'php' allows for protecting the log files via basic
100
* scripting, when they are to be stored under a publicly accessible directory.
102
* NOTE: Leaving it blank will default to 'log'.
104
'fileExtension' => '',
107
* The file system permissions to be applied on newly created log files.
109
* IMPORTANT: This MUST be an integer (no quotes) and you MUST use octal
110
* integer notation (i.e. 0700, 0644, etc.)
112
'filePermissions' => 0644,
115
* Logging Directory Path
117
* By default, logs are written to WRITEPATH . 'logs/'
118
* Specify a different destination here, if desired.
124
* The ChromeLoggerHandler requires the use of the Chrome web browser
125
* and the ChromeLogger extension. Uncomment this block to use it.
127
// 'CodeIgniter\Log\Handlers\ChromeLoggerHandler' => [
129
// * The log levels that this handler will handle.
131
// 'handles' => ['critical', 'alert', 'emergency', 'debug',
132
// 'error', 'info', 'notice', 'warning'],
136
* The ErrorlogHandler writes the logs to PHP's native `error_log()` function.
137
* Uncomment this block to use it.
139
// 'CodeIgniter\Log\Handlers\ErrorlogHandler' => [
140
// /* The log levels this handler can handle. */
141
// 'handles' => ['critical', 'alert', 'emergency', 'debug', 'error', 'info', 'notice', 'warning'],
144
// * The message type where the error should go. Can be 0 or 4, or use the
145
// * class constants: `ErrorlogHandler::TYPE_OS` (0) or `ErrorlogHandler::TYPE_SAPI` (4)
147
// 'messageType' => 0,