2020-08-04 11:25:22 +00:00
|
|
|
<?php
|
|
|
|
|
2021-06-08 09:52:11 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-08-04 11:25:22 +00:00
|
|
|
namespace Config;
|
2020-05-27 18:46:16 +02:00
|
|
|
|
|
|
|
use CodeIgniter\Config\BaseConfig;
|
2021-05-19 16:35:13 +00:00
|
|
|
use CodeIgniter\Log\Handlers\FileHandler;
|
2020-05-27 18:46:16 +02:00
|
|
|
|
|
|
|
class Logger extends BaseConfig
|
|
|
|
{
|
2021-04-02 17:20:02 +00:00
|
|
|
/**
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
* Error Logging Threshold
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* You can enable error logging by setting a threshold over zero. The
|
|
|
|
* threshold determines what gets logged. Any values below or equal to the
|
|
|
|
* threshold will be logged.
|
|
|
|
*
|
|
|
|
* Threshold options are:
|
|
|
|
*
|
|
|
|
* - 0 = Disables logging, Error logging TURNED OFF
|
|
|
|
* - 1 = Emergency Messages - System is unusable
|
|
|
|
* - 2 = Alert Messages - Action Must Be Taken Immediately
|
|
|
|
* - 3 = Critical Messages - Application component unavailable, unexpected exception.
|
|
|
|
* - 4 = Runtime Errors - Don't need immediate action, but should be monitored.
|
|
|
|
* - 5 = Warnings - Exceptional occurrences that are not errors.
|
|
|
|
* - 6 = Notices - Normal but significant events.
|
|
|
|
* - 7 = Info - Interesting events, like user logging in, etc.
|
|
|
|
* - 8 = Debug - Detailed debug information.
|
|
|
|
* - 9 = All Messages
|
|
|
|
*
|
|
|
|
* You can also pass an array with threshold levels to show individual error types
|
|
|
|
*
|
|
|
|
* array(1, 2, 3, 8) = Emergency, Alert, Critical, and Debug messages
|
|
|
|
*
|
|
|
|
* For a live site you'll usually enable Critical or higher (3) to be logged otherwise
|
|
|
|
* your log files will fill up very fast.
|
|
|
|
*
|
2021-05-18 17:16:36 +00:00
|
|
|
* @var int|int[]
|
2021-04-02 17:20:02 +00:00
|
|
|
*/
|
2021-05-19 16:35:13 +00:00
|
|
|
public int | array $threshold = 4;
|
2020-05-27 18:46:16 +02:00
|
|
|
|
2021-04-02 17:20:02 +00:00
|
|
|
/**
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
* Date Format for Logs
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* Each item that is logged has an associated date. You can use PHP date
|
|
|
|
* codes to set your own date formatting
|
|
|
|
*/
|
2021-05-14 17:59:35 +00:00
|
|
|
public string $dateFormat = 'Y-m-d H:i:s';
|
2020-05-27 18:46:16 +02:00
|
|
|
|
2021-04-02 17:20:02 +00:00
|
|
|
/**
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
* Log Handlers
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* The logging system supports multiple actions to be taken when something
|
|
|
|
* is logged. This is done by allowing for multiple Handlers, special classes
|
|
|
|
* designed to write the log to their chosen destinations, whether that is
|
2022-08-20 10:08:15 +00:00
|
|
|
* a file on the server, a cloud-based service, or even taking actions such
|
2021-04-02 17:20:02 +00:00
|
|
|
* as emailing the dev team.
|
|
|
|
*
|
|
|
|
* Each handler is defined by the class name used for that handler, and it
|
|
|
|
* MUST implement the `CodeIgniter\Log\Handlers\HandlerInterface` interface.
|
|
|
|
*
|
|
|
|
* The value of each key is an array of configuration items that are sent
|
|
|
|
* to the constructor of each handler. The only required configuration item
|
|
|
|
* is the 'handles' element, which must be an array of integer log levels.
|
|
|
|
* This is most easily handled by using the constants defined in the
|
|
|
|
* `Psr\Log\LogLevel` class.
|
|
|
|
*
|
|
|
|
* Handlers are executed in the order defined in this array, starting with
|
|
|
|
* the handler on top and continuing down.
|
|
|
|
*
|
2021-05-18 17:16:36 +00:00
|
|
|
* @var array<string, mixed>
|
2021-04-02 17:20:02 +00:00
|
|
|
*/
|
2021-05-14 17:59:35 +00:00
|
|
|
public array $handlers = [
|
2021-04-02 17:20:02 +00:00
|
|
|
/*
|
|
|
|
* --------------------------------------------------------------------
|
|
|
|
* File Handler
|
|
|
|
* --------------------------------------------------------------------
|
|
|
|
*/
|
2021-05-06 14:00:48 +00:00
|
|
|
FileHandler::class => [
|
2020-06-10 15:00:12 +00:00
|
|
|
/*
|
|
|
|
* The log levels that this handler will handle.
|
|
|
|
*/
|
2021-05-19 16:35:13 +00:00
|
|
|
'handles' => ['critical', 'alert', 'emergency', 'debug', 'error', 'info', 'notice', 'warning'],
|
2020-05-27 18:46:16 +02:00
|
|
|
|
2020-06-10 15:00:12 +00:00
|
|
|
/*
|
|
|
|
* The default filename extension for log files.
|
|
|
|
* An extension of 'php' allows for protecting the log files via basic
|
|
|
|
* scripting, when they are to be stored under a publicly accessible directory.
|
|
|
|
*
|
|
|
|
* Note: Leaving it blank will default to 'log'.
|
|
|
|
*/
|
|
|
|
'fileExtension' => '',
|
2020-05-27 18:46:16 +02:00
|
|
|
|
2020-06-10 15:00:12 +00:00
|
|
|
/*
|
|
|
|
* The file system permissions to be applied on newly created log files.
|
|
|
|
*
|
|
|
|
* IMPORTANT: This MUST be an integer (no quotes) and you MUST use octal
|
|
|
|
* integer notation (i.e. 0700, 0644, etc.)
|
|
|
|
*/
|
|
|
|
'filePermissions' => 0644,
|
2020-05-27 18:46:16 +02:00
|
|
|
|
2020-06-10 15:00:12 +00:00
|
|
|
/*
|
|
|
|
* Logging Directory Path
|
|
|
|
*
|
|
|
|
* By default, logs are written to WRITEPATH . 'logs/'
|
|
|
|
* Specify a different destination here, if desired.
|
|
|
|
*/
|
|
|
|
'path' => '',
|
|
|
|
],
|
|
|
|
];
|
2020-05-27 18:46:16 +02:00
|
|
|
}
|