-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from mteu/feature/limit-logger-responsibility-…
…by-loglevel
- Loading branch information
Showing
5 changed files
with
232 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the TYPO3 CMS extension "mteu/typo3-stream-writer". | ||
* | ||
* Copyright (C) 2024 Martin Adler <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
namespace mteu\StreamWriter\Log; | ||
|
||
/** | ||
* @codeCoverageIgnore | ||
*/ | ||
enum LogLevel: string | ||
{ | ||
case ALERT = 'alert'; | ||
case CRITICAL = 'critical'; | ||
case DEBUG = 'debug'; | ||
case EMERGENCY = 'emergency'; | ||
case ERROR = 'error'; | ||
case INFO = 'info'; | ||
case NOTICE = 'notice'; | ||
case WARNING = 'warning'; | ||
|
||
public function priority(): int | ||
{ | ||
return match ($this) { | ||
self::EMERGENCY => 8, | ||
self::ALERT => 7, | ||
self::CRITICAL => 6, | ||
self::ERROR => 5, | ||
self::WARNING => 4, | ||
self::NOTICE => 3, | ||
self::INFO => 2, | ||
self::DEBUG => 1, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# LogWriter Configuration | ||
|
||
## Options | ||
The TYPO3 Stream Writer currently supports following options: | ||
|
||
| Option | Required | Value | Description | | ||
|--------------------|----------|---------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| `outputStream` | required | [`StandardStream::Err`](../Classes/Log/Config/StandardStream.php) or <br/>[`StandardStream::Out`](../Classes/Log/Config/StandardStream.php) | Direct your stream output either to `php://stdout` or `php://sterr` | | ||
| `ignoreComponents` | optional | Array of classes to be excluded from logging via this LogWriter | Please note that classes are currently repesented by the full qualified class name syntax the TYPO3 Logging Framework uses.<br/> _This is likely to change to accept actual class strings there, too_. | | ||
| `maxLevel` | optional | `Psr\Log\LogLevel` | Although, you may go with their respective `string` representations, it is recommended to stick to `Psr\Log\LogLevel` for compatibility. | | ||
| | | | | | ||
|
||
## Example | ||
|
||
```php | ||
$GLOBALS['TYPO3_CONF_VARS']['LOG']['writerConfiguration'] = [ | ||
\Psr\Log\LogLevel::DEBUG => [ | ||
StreamWriter::class => [ | ||
'outputStream' => StandardStream::Out, | ||
'ignoreComponents' => [ | ||
'TYPO3.CMS.Core.Authentication.BackendUserAuthentication', | ||
'TYPO3.CMS.Frontend.Authentication.FrontendUserAuthentication', | ||
], | ||
'maxLevel' => Psr\Log\LogLevel::WARNING, | ||
], | ||
], | ||
]; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.