Skip to content

Commit 4528c42

Browse files
authored
Merge pull request #345 from MightyCreak/chore/use-log-levels
chore: replace deprecated log levels in Logger by Level::*
2 parents 4de0502 + bc9da62 commit 4528c42

File tree

4 files changed

+25
-24
lines changed

4 files changed

+25
-24
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ copy this contents:
6666
```php
6767
<?php
6868

69-
use Monolog\Logger as Log;
69+
use Monolog\Level;
7070

7171
$CONFIG = array(
7272
"info" => array(
73-
"log_level" => Log::DEBUG,
73+
"log_level" => Level::Debug,
7474
),
7575
);
7676
```

config/config.default.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
// Default configuration for Mesamatrix.
44
// Values can be overwritten in a user defined config/config.php file.
55

6-
use Monolog\Logger as Log;
6+
use Monolog\Level;
77

8-
/* available log levels:
9-
* Log::EMERGENCY
10-
* Log::ALERT
11-
* Log::CRITICAL
12-
* Log::ERROR
13-
* Log::WARNING (default)
14-
* Log::NOTICE
15-
* Log::INFO
16-
* Log::DEBUG
8+
/* Available log levels:
9+
* Level::Emergency
10+
* Level::Alert
11+
* Level::Critical
12+
* Level::Error
13+
* Level::Warning (default)
14+
* Level::Notice
15+
* Level::Info
16+
* Level::Debug
1717
*/
1818

1919
return [
2020
"info" => [
21-
"log_level" => Log::WARNING,
21+
"log_level" => Level::Warning,
2222
"version" => "3.0",
2323
"title" => "The Mesa drivers matrix",
2424
"description" => "Show Mesa progress for the OpenGL, OpenGL ES, Vulkan and OpenCL drivers implementations into an easy to read HTML page.",

src/Controller/RssController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
namespace Mesamatrix\Controller;
44

55
use Mesamatrix\Mesamatrix;
6-
use Symfony\Component\HttpFoundation\Response as HTTPResponse;
76
use Suin\RSSWriter\Feed as RSSFeed;
87
use Suin\RSSWriter\Channel as RSSChannel;
98
use Suin\RSSWriter\Item as RSSItem;
9+
use Symfony\Component\HttpFoundation\Response as HttpResponse;
1010

1111
class RssController
1212
{
@@ -37,9 +37,9 @@ public function run(): void
3737
}
3838

3939
// Send response.
40-
$response = new HTTPResponse(
40+
$response = new HttpResponse(
4141
$rssContents,
42-
HTTPResponse::HTTP_OK,
42+
HttpResponse::HTTP_OK,
4343
['Content-Type' => 'text/xml']
4444
);
4545

@@ -61,7 +61,7 @@ private function rssGenerationNeeded(string $featuresXmlFilepath, string $rssFil
6161
return true;
6262
}
6363

64-
private function generateRss(string $featuresXmlFilepath): string
64+
private function generateRss(string $featuresXmlFilepath): ?string
6565
{
6666
$xml = simplexml_load_file($featuresXmlFilepath);
6767
if (!$xml) {

src/Mesamatrix.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,20 @@
2121

2222
namespace Mesamatrix;
2323

24+
use Monolog\Level;
2425
use Monolog\Logger;
2526
use Monolog\ErrorHandler;
2627
use Monolog\Handler\ErrorLogHandler;
2728
use Monolog\Handler\StreamHandler;
28-
use Symfony\Component\HttpFoundation\Request as HTTPRequest;
29+
use Symfony\Component\HttpFoundation\Request as HttpRequest;
2930

3031
class Mesamatrix
3132
{
3233
public static string $serverRoot; // Path to root of installation
3334
public static string $configDir; // Path to configuration directory
3435
public static Config $config;
3536
public static Logger $logger;
36-
public static HTTPRequest $request;
37+
public static HttpRequest $request;
3738

3839
public static function init()
3940
{
@@ -44,7 +45,7 @@ public static function init()
4445
self::$logger = new Logger('logger');
4546
self::$logger->pushHandler(new ErrorLogHandler(
4647
ErrorLogHandler::OPERATING_SYSTEM,
47-
Logger::NOTICE
48+
Level::Notice
4849
));
4950
ErrorHandler::register(self::$logger);
5051

@@ -58,7 +59,7 @@ public static function init()
5859
}
5960

6061
// register the log file
61-
$logLevel = self::$config->getValue('info', 'log_level', Logger::WARNING);
62+
$logLevel = self::$config->getValue('info', 'log_level', Level::Warning);
6263
$logPath = $privateDir . '/mesamatrix.log';
6364
if (!file_exists($logPath) && is_dir($privateDir)) {
6465
touch($logPath);
@@ -70,7 +71,7 @@ public static function init()
7071
self::$logger->error('Error log ' . $logPath . ' is not writable!');
7172
}
7273

73-
if ($logLevel < Logger::INFO) {
74+
if ($logLevel < Level::Info) {
7475
ini_set('display_errors', '1');
7576
error_reporting(E_ALL);
7677
}
@@ -82,11 +83,11 @@ public static function init()
8283
}
8384

8485
// Initialize request
85-
self::$request = HTTPRequest::createFromGlobals();
86+
self::$request = HttpRequest::createFromGlobals();
8687

8788
self::$logger->debug('Base initialization complete');
8889

89-
self::$logger->debug('Log level: ' . self::$logger->getLevelName($logLevel));
90+
self::$logger->debug('Log level: ' . Logger::toMonologLevel($logLevel)->getName());
9091
self::$logger->debug('PHP error_reporting: 0x' . dechex(ini_get('error_reporting')));
9192
self::$logger->debug('PHP display_errors: ' . ini_get('display_errors'));
9293
}

0 commit comments

Comments
 (0)