@@ -44,7 +44,7 @@ $log = new Log($settings);
4444$log->alert('The message with {variable}', ['variable' => 'useful info']);
4545
4646// This message won't be processed by ErrorLog because the level is below ERROR
47- // but File will handle it
47+ // but * File* will handle it
4848$log->warning("You don't see anything");
4949
5050```
@@ -53,44 +53,46 @@ Configuration
5353-------------
5454
5555There are two ways of throwing the log messages
56- - register the logger at PHP's shutdown phase with
57- ``` php
58- <?php
59-
60- $logger->register();
61-
62- // or
63- register_shutdown_function([$logger, 'process']);
64-
65- // or
66- register_shutdown_function([new Log($settings), 'process']);
67- ```
68- somewhere in your bootstrap, at the very beginning of your project.
69- ** You do this only once** .
70-
71- - calling directly ` $logger->process() ` if you want immediate log messages.
72- ** This approach will dump all accumulated messages and clear the messages stack** ,
73- so at the shutdown phase (if any) the logger will be empty
56+ - automatically at the shutdown phase by using the ` Log::process() ` method somewhere in your bootstrap
57+ (at the very beginning of your project).
58+ ** You should do this only once** .
59+
60+ ```php
61+ <?php
62+
63+ $logger->register();
64+
65+ // or
66+ register_shutdown_function([$logger, 'process']);
67+
68+ // or
69+ register_shutdown_function([new Log($settings), 'process']);
70+ ```
71+
72+ - calling directly ` $logger->process() ` if you want immediate log messages.
73+ ** This call will dump all accumulated messages and clear the stack**
74+ (after that the logger will be empty)
7475
7576
7677### Log and Processor default directives
7778
7879Every log processor has it's own set of configuration directives.
79- The table shows parameters that are always present in the classes.
80+ The table shows log parameters in the classes.
8081
81- | Param | Type | Required | Default | Description |
82- | :-----------| :--------| :--------:| :------------| :--------------------------------------------------------------------- |
83- | class | string | yes | | The name of the log processor class |
84- | levels | integer | no | -1 | Packed integer for bitwise comparison. See the constants in Logger |
85- | dateformat | string | no | d/m/Y H:i: s | The datetime format for the log message |
86- | timezone | string | no | UTC | The desired timezone for the datetime log message |
82+ | Param | Type | Required | Default | Description
83+ |:-----------|:--------|:--------:|:------------|:-----------
84+ | class | string | yes | | The name of the log processor class
85+ | levels | integer | no | -1 | Packed integer for bitwise comparison. See the constants in Logger class
86+ | dateformat | string | no | d/m/Y H:i: s | The datetime format for the log message
87+ | timezone | string | no | UTC | The desired timezone for the datetime log message
8788
8889
8990### Levels example
91+
9092The messages are filtered with bitwise operator (as packed integer). Every processor will filter out the messages as
9193defined in it's ** levels** directive.
9294
93- To log only WARNING, INFO and ERROR messages set levels to
95+ For instance, to log only WARNING, INFO and ERROR messages set levels to
9496
9597``` php
9698<?php
@@ -101,29 +103,20 @@ To log only WARNING, INFO and ERROR messages set levels to
101103Tips:
102104- every processor is configured separately
103105- if you want to process all log levels, skip the ` levels ` value
104- - if you want to suppress the processor, set the level to 0
106+ - if you want to suppress a specific processor, set it's level to 0
105107
106108
107109Processors
108110----------
109111
110- - ** ErrorLog**
111- uses the [ error_log()] [ error-log ] function to send the message to PHP's logger
112-
113- - ** File**
114- saves the messages on a disk. It's a slow one
115-
116- - ** Syslog**
117- will open the system logger and send messages using the [ syslog()] [ syslog ] function
118-
119- - ** Cli**
120- for CLI applications, it can write the messages in the console
121-
122- - ** Memory**
123- will store all messages in an array. Useful for unit tests if the logger is involved
124-
125- - ** Voided**
126- is here for no particular reason and purpose. It's the fastest one tho
112+ | Class name | Description
113+ |-----------:|:-----------
114+ | ErrorLog | uses the [ error_log()] [ error-log ] function to send the message to PHP's logger
115+ | SysLog | will open the system logger and send messages using the [ syslog()] [ syslog ] function
116+ | Cli | for CLI applications, it can write the messages in the console
117+ | Memory | will store all messages in an array. Useful for unit tests if the logger is involved
118+ | File | saves the messages on a disk. It's a slow one and should be avoided
119+ | Voided | is here for no particular reason and purpose. It's the fastest one tho :)
127120
128121
129122License
@@ -134,4 +127,4 @@ The code is distributed under the terms of [The 3-Clause BSD license](LICENSE).
134127[ psr-3 ] : http://www.php-fig.org/psr/psr-3/
135128[ composer ] : https://getcomposer.org/download/
136129[ error-log ] : http://php.net/error_log
137- [ syslog ] : http://php.net/syslog
130+ [ syslog ] : http://php.net/syslog
0 commit comments