Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1ecbc0b

Browse files
committed
[MonologBridge] Remove support for monolog < 3
1 parentffe6f08 commit1ecbc0b

File tree

33 files changed

+192
-499
lines changed

33 files changed

+192
-499
lines changed

‎composer.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
"guzzlehttp/promises":"^1.4",
137137
"league/html-to-markdown":"^5.0",
138138
"masterminds/html5":"^2.7.2",
139-
"monolog/monolog":"^1.25.1|^2",
139+
"monolog/monolog":"^3",
140140
"nyholm/psr7":"^1.0",
141141
"pda/pheanstalk":"^4.0",
142142
"php-http/discovery":"^1.15",

‎src/Symfony/Bridge/Monolog/CHANGELOG.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
7.0
5+
---
6+
7+
* Drop support for monolog < 3.0
8+
49
6.4
510
---
611

‎src/Symfony/Bridge/Monolog/Command/ServerLogCommand.php‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313

1414
useMonolog\Formatter\FormatterInterface;
1515
useMonolog\Handler\HandlerInterface;
16-
useMonolog\Logger;
16+
useMonolog\Level;
17+
useMonolog\LogRecord;
1718
useSymfony\Bridge\Monolog\Formatter\ConsoleFormatter;
1819
useSymfony\Bridge\Monolog\Handler\ConsoleHandler;
1920
useSymfony\Component\Console\Attribute\AsCommand;
@@ -86,7 +87,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8687
}
8788

8889
$this->handler =newConsoleHandler($output,true, [
89-
OutputInterface::VERBOSITY_NORMAL =>Logger::DEBUG,
90+
OutputInterface::VERBOSITY_NORMAL =>Level::Debug,
9091
]);
9192

9293
$this->handler->setFormatter(newConsoleFormatter([
@@ -145,7 +146,7 @@ private function getLogs($socket): iterable
145146
}
146147
}
147148

148-
privatefunctiondisplayLog(OutputInterface$output,int$clientId,array$record):void
149+
privatefunctiondisplayLog(OutputInterface$output,int$clientId,LogRecord$record):void
149150
{
150151
if (isset($record['log_id'])) {
151152
$clientId =unpack('H*',$record['log_id'])[1];

‎src/Symfony/Bridge/Monolog/Formatter/CompatibilityFormatter.php‎

Lines changed: 0 additions & 51 deletions
This file was deleted.

‎src/Symfony/Bridge/Monolog/Formatter/ConsoleFormatter.php‎

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespaceSymfony\Bridge\Monolog\Formatter;
1313

1414
useMonolog\Formatter\FormatterInterface;
15-
useMonolog\Logger;
15+
useMonolog\Level;
1616
useMonolog\LogRecord;
1717
useSymfony\Component\Console\Formatter\OutputFormatter;
1818
useSymfony\Component\VarDumper\Cloner\Data;
@@ -28,20 +28,18 @@
2828
*/
2929
finalclass ConsoleFormatterimplements FormatterInterface
3030
{
31-
use CompatibilityFormatter;
32-
3331
publicconstSIMPLE_FORMAT ="%datetime% %start_tag%%level_name%%end_tag% <comment>[%channel%]</> %message%%context%%extra%\n";
3432
publicconstSIMPLE_DATE ='H:i:s';
3533

3634
privateconstLEVEL_COLOR_MAP = [
37-
Logger::DEBUG =>'fg=white',
38-
Logger::INFO =>'fg=green',
39-
Logger::NOTICE =>'fg=blue',
40-
Logger::WARNING =>'fg=cyan',
41-
Logger::ERROR =>'fg=yellow',
42-
Logger::CRITICAL =>'fg=red',
43-
Logger::ALERT =>'fg=red',
44-
Logger::EMERGENCY =>'fg=white;bg=red',
35+
Level::Debug->value =>'fg=white',
36+
Level::Info->value =>'fg=green',
37+
Level::Notice->value =>'fg=blue',
38+
Level::Warning->value =>'fg=cyan',
39+
Level::Error->value =>'fg=yellow',
40+
Level::Critical->value =>'fg=red',
41+
Level::Alert->value =>'fg=red',
42+
Level::Emergency->value =>'fg=white;bg=red',
4543
];
4644

4745
privatearray$options;
@@ -98,11 +96,9 @@ public function formatBatch(array $records): mixed
9896
return$records;
9997
}
10098

101-
privatefunctiondoFormat(array|LogRecord$record):mixed
99+
publicfunctionformat(LogRecord$record):mixed
102100
{
103-
if ($recordinstanceof LogRecord) {
104-
$record =$record->toArray();
105-
}
101+
$record =$record->toArray();
106102
$record =$this->replacePlaceHolder($record);
107103

108104
if (!$this->options['ignore_empty_context_and_extra'] || !empty($record['context'])) {

‎src/Symfony/Bridge/Monolog/Formatter/VarDumperFormatter.php‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,16 @@
2020
*/
2121
finalclass VarDumperFormatterimplements FormatterInterface
2222
{
23-
use CompatibilityFormatter;
24-
2523
privateVarCloner$cloner;
2624

2725
publicfunction__construct(VarCloner$cloner =null)
2826
{
2927
$this->cloner =$cloner ??newVarCloner();
3028
}
3129

32-
privatefunctiondoFormat(array|LogRecord$record):mixed
30+
publicfunctionformat(LogRecord$record):mixed
3331
{
34-
if ($recordinstanceof LogRecord) {
35-
$record =$record->toArray();
36-
}
32+
$record =$record->toArray();
3733

3834
$record['context'] =$this->cloner->cloneVar($record['context']);
3935
$record['extra'] =$this->cloner->cloneVar($record['extra']);

‎src/Symfony/Bridge/Monolog/Handler/CompatibilityHandler.php‎

Lines changed: 0 additions & 51 deletions
This file was deleted.

‎src/Symfony/Bridge/Monolog/Handler/CompatibilityProcessingHandler.php‎

Lines changed: 0 additions & 51 deletions
This file was deleted.

‎src/Symfony/Bridge/Monolog/Handler/ConsoleHandler.php‎

Lines changed: 11 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
useMonolog\Formatter\FormatterInterface;
1515
useMonolog\Formatter\LineFormatter;
1616
useMonolog\Handler\AbstractProcessingHandler;
17-
useMonolog\Logger;
17+
useMonolog\Level;
1818
useMonolog\LogRecord;
1919
useSymfony\Bridge\Monolog\Formatter\ConsoleFormatter;
2020
useSymfony\Component\Console\ConsoleEvents;
@@ -25,42 +25,6 @@
2525
useSymfony\Component\EventDispatcher\EventSubscriberInterface;
2626
useSymfony\Component\VarDumper\Dumper\CliDumper;
2727

28-
if (Logger::API >=3) {
29-
/**
30-
* The base class for compatibility between Monolog 3 LogRecord and Monolog 1/2 array records.
31-
*
32-
* @author Jordi Boggiano <j.boggiano@seld.be>
33-
*
34-
* @internal
35-
*/
36-
trait CompatibilityIsHandlingHandler
37-
{
38-
abstractprivatefunctiondoIsHandling(array|LogRecord$record):bool;
39-
40-
publicfunctionisHandling(LogRecord$record):bool
41-
{
42-
return$this->doIsHandling($record);
43-
}
44-
}
45-
}else {
46-
/**
47-
* The base class for compatibility between Monolog 3 LogRecord and Monolog 1/2 array records.
48-
*
49-
* @author Jordi Boggiano <j.boggiano@seld.be>
50-
*
51-
* @internal
52-
*/
53-
trait CompatibilityIsHandlingHandler
54-
{
55-
abstractprivatefunctiondoIsHandling(array|LogRecord$record):bool;
56-
57-
publicfunctionisHandling(array$record):bool
58-
{
59-
return$this->doIsHandling($record);
60-
}
61-
}
62-
}
63-
6428
/**
6529
* Writes logs to the console output depending on its verbosity setting.
6630
*
@@ -80,17 +44,13 @@ public function isHandling(array $record): bool
8044
*/
8145
finalclass ConsoleHandlerextends AbstractProcessingHandlerimplements EventSubscriberInterface
8246
{
83-
use CompatibilityHandler;
84-
use CompatibilityIsHandlingHandler;
85-
use CompatibilityProcessingHandler;
86-
8747
private ?OutputInterface$output;
8848
privatearray$verbosityLevelMap = [
89-
OutputInterface::VERBOSITY_QUIET =>Logger::ERROR,
90-
OutputInterface::VERBOSITY_NORMAL =>Logger::WARNING,
91-
OutputInterface::VERBOSITY_VERBOSE =>Logger::NOTICE,
92-
OutputInterface::VERBOSITY_VERY_VERBOSE =>Logger::INFO,
93-
OutputInterface::VERBOSITY_DEBUG =>Logger::DEBUG,
49+
OutputInterface::VERBOSITY_QUIET =>Level::Error,
50+
OutputInterface::VERBOSITY_NORMAL =>Level::Warning,
51+
OutputInterface::VERBOSITY_VERBOSE =>Level::Notice,
52+
OutputInterface::VERBOSITY_VERY_VERBOSE =>Level::Info,
53+
OutputInterface::VERBOSITY_DEBUG =>Level::Debug,
9454
];
9555
privatearray$consoleFormatterOptions;
9656

@@ -103,7 +63,7 @@ final class ConsoleHandler extends AbstractProcessingHandler implements EventSub
10363
*/
10464
publicfunction__construct(OutputInterface$output =null,bool$bubble =true,array$verbosityLevelMap = [],array$consoleFormatterOptions = [])
10565
{
106-
parent::__construct(Logger::DEBUG,$bubble);
66+
parent::__construct(Level::Debug,$bubble);
10767
$this->output =$output;
10868

10969
if ($verbosityLevelMap) {
@@ -113,12 +73,12 @@ public function __construct(OutputInterface $output = null, bool $bubble = true,
11373
$this->consoleFormatterOptions =$consoleFormatterOptions;
11474
}
11575

116-
privatefunctiondoIsHandling(array|LogRecord$record):bool
76+
publicfunctionisHandling(LogRecord$record):bool
11777
{
11878
return$this->updateLevel() &&parent::isHandling($record);
11979
}
12080

121-
privatefunctiondoHandle(array|LogRecord$record):bool
81+
publicfunctionhandle(LogRecord$record):bool
12282
{
12383
// we have to update the logging level each time because the verbosity of the
12484
// console output might have changed in the meantime (it is not immutable)
@@ -173,7 +133,7 @@ public static function getSubscribedEvents(): array
173133
];
174134
}
175135

176-
privatefunctiondoWrite(array|LogRecord$record):void
136+
protectedfunctionwrite(LogRecord$record):void
177137
{
178138
// at this point we've determined for sure that we want to output the record, so use the output's own verbosity
179139
$this->output->write((string)$record['formatted'],false,$this->output->getVerbosity());
@@ -209,7 +169,7 @@ private function updateLevel(): bool
209169
if (isset($this->verbosityLevelMap[$verbosity])) {
210170
$this->setLevel($this->verbosityLevelMap[$verbosity]);
211171
}else {
212-
$this->setLevel(Logger::DEBUG);
172+
$this->setLevel(Level::Debug);
213173
}
214174

215175
returntrue;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp