diff options
Diffstat (limited to 'lib/public/Log')
-rw-r--r-- | lib/public/Log/Audit/CriticalActionPerformedEvent.php | 25 | ||||
-rw-r--r-- | lib/public/Log/BeforeMessageLoggedEvent.php | 66 | ||||
-rw-r--r-- | lib/public/Log/IDataLogger.php | 21 | ||||
-rw-r--r-- | lib/public/Log/IFileBased.php | 23 | ||||
-rw-r--r-- | lib/public/Log/ILogFactory.php | 34 | ||||
-rw-r--r-- | lib/public/Log/IWriter.php | 22 | ||||
-rw-r--r-- | lib/public/Log/RotationTrait.php | 25 | ||||
-rw-r--r-- | lib/public/Log/functions.php | 24 |
8 files changed, 89 insertions, 151 deletions
diff --git a/lib/public/Log/Audit/CriticalActionPerformedEvent.php b/lib/public/Log/Audit/CriticalActionPerformedEvent.php index 79c67e5b8bd..da7bdda8c73 100644 --- a/lib/public/Log/Audit/CriticalActionPerformedEvent.php +++ b/lib/public/Log/Audit/CriticalActionPerformedEvent.php @@ -3,25 +3,8 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2021 Joas Schilling <coding@schilljs.com> - * - * @author Joas Schilling <coding@schilljs.com> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ namespace OCP\Log\Audit; @@ -49,8 +32,8 @@ class CriticalActionPerformedEvent extends Event { * @since 22.0.0 */ public function __construct(string $logMessage, - array $parameters = [], - bool $obfuscateParameters = false) { + array $parameters = [], + bool $obfuscateParameters = false) { parent::__construct(); $this->logMessage = $logMessage; $this->parameters = $parameters; diff --git a/lib/public/Log/BeforeMessageLoggedEvent.php b/lib/public/Log/BeforeMessageLoggedEvent.php new file mode 100644 index 00000000000..8500a769bca --- /dev/null +++ b/lib/public/Log/BeforeMessageLoggedEvent.php @@ -0,0 +1,66 @@ +<?php + +declare(strict_types=1); +/** + * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace OCP\Log; + +use OCP\EventDispatcher\Event; + +/** + * Even for when a log item is being logged + * + * @since 28.0.0 + */ +class BeforeMessageLoggedEvent extends Event { + private int $level; + private string $app; + private $message; + + /** + * @param string $app + * @param int $level + * @param array $message + * @since 28.0.0 + */ + public function __construct(string $app, int $level, array $message) { + $this->level = $level; + $this->app = $app; + $this->message = $message; + } + + /** + * Get the level of the log item + * + * @return int + * @since 28.0.0 + */ + public function getLevel(): int { + return $this->level; + } + + + /** + * Get the app context of the log item + * + * @return string + * @since 28.0.0 + */ + public function getApp(): string { + return $this->app; + } + + + /** + * Get the message of the log item + * + * @return array + * @since 28.0.0 + */ + public function getMessage(): array { + return $this->message; + } +} diff --git a/lib/public/Log/IDataLogger.php b/lib/public/Log/IDataLogger.php index 2a261b2b665..c3334d0bf12 100644 --- a/lib/public/Log/IDataLogger.php +++ b/lib/public/Log/IDataLogger.php @@ -3,25 +3,8 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2019 Arthur Schiwon <blizzz@arthur-schiwon.de> - * - * @author Arthur Schiwon <blizzz@arthur-schiwon.de> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ namespace OCP\Log; diff --git a/lib/public/Log/IFileBased.php b/lib/public/Log/IFileBased.php index 54f9e7d754a..ace10ee1b68 100644 --- a/lib/public/Log/IFileBased.php +++ b/lib/public/Log/IFileBased.php @@ -1,25 +1,8 @@ <?php + /** - * @copyright Copyright (c) 2018 Arthur Schiwon <blizzz@arthur-schiwon.de> - * - * @author Arthur Schiwon <blizzz@arthur-schiwon.de> - * @author Christoph Wurst <christoph@winzerhof-wurst.at> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ namespace OCP\Log; diff --git a/lib/public/Log/ILogFactory.php b/lib/public/Log/ILogFactory.php index 6bbcf93bca8..db7adca2192 100644 --- a/lib/public/Log/ILogFactory.php +++ b/lib/public/Log/ILogFactory.php @@ -1,30 +1,11 @@ <?php + /** - * @copyright Copyright (c) 2018 Arthur Schiwon <blizzz@arthur-schiwon.de> - * - * @author Arthur Schiwon <blizzz@arthur-schiwon.de> - * @author Christoph Wurst <christoph@winzerhof-wurst.at> - * @author Johannes Ernst <jernst@indiecomputing.com> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ namespace OCP\Log; -use OCP\ILogger; use Psr\Log\LoggerInterface; /** @@ -42,15 +23,6 @@ interface ILogFactory { /** * @param string $path - * @return ILogger - * @since 14.0.0 - * @deprecated use \OCP\Log\ILogFactory::getCustomPsrLogger - * @see \OCP\Log\ILogFactory::getCustomPsrLogger - */ - public function getCustomLogger(string $path): ILogger; - - /** - * @param string $path * @param string $type * @param string $tag * @return LoggerInterface diff --git a/lib/public/Log/IWriter.php b/lib/public/Log/IWriter.php index 3c7ec84e8c0..2fcbc094881 100644 --- a/lib/public/Log/IWriter.php +++ b/lib/public/Log/IWriter.php @@ -1,24 +1,8 @@ <?php + /** - * @copyright Copyright (c) 2018 Arthur Schiwon <blizzz@arthur-schiwon.de> - * - * @author Arthur Schiwon <blizzz@arthur-schiwon.de> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ namespace OCP\Log; diff --git a/lib/public/Log/RotationTrait.php b/lib/public/Log/RotationTrait.php index b2415b6f61f..73b3b16b665 100644 --- a/lib/public/Log/RotationTrait.php +++ b/lib/public/Log/RotationTrait.php @@ -1,25 +1,8 @@ <?php + /** - * @copyright Copyright (c) 2018 Arthur Schiwon <blizzz@arthur-schiwon.de> - * - * @author Arthur Schiwon <blizzz@arthur-schiwon.de> - * @author dartcafe <github@dartcafe.de> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ namespace OCP\Log; @@ -47,7 +30,7 @@ trait RotationTrait { * @since 14.0.0 */ protected function rotate():string { - $rotatedFile = $this->filePath.'.1'; + $rotatedFile = $this->filePath . '.1'; rename($this->filePath, $rotatedFile); return $rotatedFile; } diff --git a/lib/public/Log/functions.php b/lib/public/Log/functions.php index ac043b4d958..75e07deab34 100644 --- a/lib/public/Log/functions.php +++ b/lib/public/Log/functions.php @@ -2,25 +2,9 @@ declare(strict_types=1); -/* - * @copyright 2022 Christoph Wurst <christoph@winzerhof-wurst.at> - * - * @author 2022 Christoph Wurst <christoph@winzerhof-wurst.at> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. +/** + * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ namespace OCP\Log; @@ -48,7 +32,7 @@ use function class_exists; * @return LoggerInterface * @since 24.0.0 */ -function logger(string $appId = null): LoggerInterface { +function logger(?string $appId = null): LoggerInterface { /** @psalm-suppress TypeDoesNotContainNull false-positive, it may contain null if we are logging from initialization */ if (!class_exists(OC::class) || OC::$server === null) { // If someone calls this log before Nextcloud is initialized, there is |