nextcloud/lib
Christoph Wurst 29b66f5225
Add a helper function that makes it easier to log from anywhere
Our DI is able to inject a logger implementation to any server and app
class if they want one. However, sometimes DI isn't applicable or hard
to add. In those cases we typically fell back to the *service locator*
pattern where we acquired a logger from the server via a global
variable.

There were some issues with that
* `\OC` is a private class, apps are not supposed to use it
* `\OC::$server` is a global variable, a well known anti-pattern
* `\OC::$server->get(...)` uses the service locator anti-pattern
* `\OC::$server->get(...)` may throw
* `\OC::$server->get(LoggerInterface::class)` is not scoped to an app

With this patch I'm proposing a new helper function ``\OCP\Log\logger``
that can be used to acquire a logger more easily. This function is meant
to be public API and therefore apps may use it and there is an optional
parameter to specifiy the app ID.
The function hides all the ugly details about the global variable and
the potentially thrown exceptions from the user. Therefore it's
guaranteed that you always get a logger instance. In the worst case you
get a noop, though those occasions should be rare.

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2021-04-20 23:04:00 +02:00
..
composer Add a helper function that makes it easier to log from anywhere 2021-04-20 23:04:00 +02:00
l10n [tx-robot] updated from transifex 2021-04-15 02:25:10 +00:00
private Separate settings for remote share expiration 2021-04-15 10:06:09 +02:00
public Add a helper function that makes it easier to log from anywhere 2021-04-20 23:04:00 +02:00
autoloader.php Bump nextcloud/coding-standard from 0.3.0 to 0.5.0 2021-02-18 13:31:24 +01:00
base.php Don't hardcode the product name to Nextcloud but use the theming value 2021-03-22 16:32:35 +01:00
versioncheck.php Update all license headers for Nextcloud 21 2020-12-16 18:48:22 +01:00