ci4

Форк
0
/
Logger.php 
150 строк · 5.9 Кб
1
<?php
2

3
namespace Config;
4

5
use CodeIgniter\Config\BaseConfig;
6
use CodeIgniter\Log\Handlers\FileHandler;
7

8
class Logger extends BaseConfig
9
{
10
    /**
11
     * --------------------------------------------------------------------------
12
     * Error Logging Threshold
13
     * --------------------------------------------------------------------------
14
     *
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.
18
     *
19
     * Threshold options are:
20
     *
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.
30
     * - 9 = All Messages
31
     *
32
     * You can also pass an array with threshold levels to show individual error types
33
     *
34
     *     array(1, 2, 3, 8) = Emergency, Alert, Critical, and Debug messages
35
     *
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.
38
     *
39
     * @var int|list<int>
40
     */
41
    public $threshold = (ENVIRONMENT === 'production') ? 4 : 9;
42

43
    /**
44
     * --------------------------------------------------------------------------
45
     * Date Format for Logs
46
     * --------------------------------------------------------------------------
47
     *
48
     * Each item that is logged has an associated date. You can use PHP date
49
     * codes to set your own date formatting
50
     */
51
    public string $dateFormat = 'Y-m-d H:i:s';
52

53
    /**
54
     * --------------------------------------------------------------------------
55
     * Log Handlers
56
     * --------------------------------------------------------------------------
57
     *
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.
63
     *
64
     * Each handler is defined by the class name used for that handler, and it
65
     * MUST implement the `CodeIgniter\Log\Handlers\HandlerInterface` interface.
66
     *
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.
72
     *
73
     * Handlers are executed in the order defined in this array, starting with
74
     * the handler on top and continuing down.
75
     *
76
     * @var array<class-string, array<string, int|list<string>|string>>
77
     */
78
    public array $handlers = [
79
        /*
80
         * --------------------------------------------------------------------
81
         * File Handler
82
         * --------------------------------------------------------------------
83
         */
84
        FileHandler::class => [
85
            // The log levels that this handler will handle.
86
            'handles' => [
87
                'critical',
88
                'alert',
89
                'emergency',
90
                'debug',
91
                'error',
92
                'info',
93
                'notice',
94
                'warning',
95
            ],
96

97
            /*
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.
101
             *
102
             * NOTE: Leaving it blank will default to 'log'.
103
             */
104
            'fileExtension' => '',
105

106
            /*
107
             * The file system permissions to be applied on newly created log files.
108
             *
109
             * IMPORTANT: This MUST be an integer (no quotes) and you MUST use octal
110
             * integer notation (i.e. 0700, 0644, etc.)
111
             */
112
            'filePermissions' => 0644,
113

114
            /*
115
             * Logging Directory Path
116
             *
117
             * By default, logs are written to WRITEPATH . 'logs/'
118
             * Specify a different destination here, if desired.
119
             */
120
            'path' => '',
121
        ],
122

123
        /*
124
         * The ChromeLoggerHandler requires the use of the Chrome web browser
125
         * and the ChromeLogger extension. Uncomment this block to use it.
126
         */
127
        // 'CodeIgniter\Log\Handlers\ChromeLoggerHandler' => [
128
        //     /*
129
        //      * The log levels that this handler will handle.
130
        //      */
131
        //     'handles' => ['critical', 'alert', 'emergency', 'debug',
132
        //                   'error', 'info', 'notice', 'warning'],
133
        // ],
134

135
        /*
136
         * The ErrorlogHandler writes the logs to PHP's native `error_log()` function.
137
         * Uncomment this block to use it.
138
         */
139
        // 'CodeIgniter\Log\Handlers\ErrorlogHandler' => [
140
        //     /* The log levels this handler can handle. */
141
        //     'handles' => ['critical', 'alert', 'emergency', 'debug', 'error', 'info', 'notice', 'warning'],
142
        //
143
        //     /*
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)
146
        //     */
147
        //     'messageType' => 0,
148
        // ],
149
    ];
150
}
151

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.