1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-06 13:16:39 +02:00

Convert level/levelName to enums (#1656)

This commit is contained in:
Jordi Boggiano
2022-04-19 21:49:03 +02:00
committed by GitHub
parent 248673e858
commit 2d006a8472
138 changed files with 1297 additions and 1216 deletions

View File

@@ -90,7 +90,7 @@ use Monolog\Handler\FirePHPHandler;
// Create the logger
$logger = new Logger('my_logger');
// Now add some handlers
$logger->pushHandler(new StreamHandler(__DIR__.'/my_app.log', Logger::DEBUG));
$logger->pushHandler(new StreamHandler(__DIR__.'/my_app.log', Level::Debug));
$logger->pushHandler(new FirePHPHandler());
// You can now use your logger
@@ -170,7 +170,7 @@ use Monolog\Handler\StreamHandler;
use Monolog\Handler\FirePHPHandler;
// Create some handlers
$stream = new StreamHandler(__DIR__.'/my_app.log', Logger::DEBUG);
$stream = new StreamHandler(__DIR__.'/my_app.log', Level::Debug);
$firephp = new FirePHPHandler();
// Create the main logger of the app
@@ -205,7 +205,7 @@ You can choose between predefined formatter classes or write your own (e.g. a mu
> A very useful formatter to look at, is the `LineFormatter`.
>
> This formatter, as its name might indicate, is able to return a lineal string representation of the log record provided.
>
>
> It is also capable to interpolate values from the log record, into the output format template used by the formatter to generate the final result, and in order to do it, you need to provide the log record values you are interested in, in the output template string using the form %value%, e.g: "'%context.foo% => %extra.foo%'" , in this example the values $record->context["foo"] and $record->extra["foo"] will be rendered as part of th final result.
In the following example, we demonstrate how to:
@@ -229,7 +229,7 @@ $output = "%datetime% > %level_name% > %message% %context% %extra%\n";
$formatter = new LineFormatter($output, $dateFormat);
// Create a handler
$stream = new StreamHandler(__DIR__.'/my_app.log', Logger::DEBUG);
$stream = new StreamHandler(__DIR__.'/my_app.log', Level::Debug);
$stream->setFormatter($formatter);
// bind it to a logger object