server/lib/public
Christoph Wurst 450136b7cf
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>
2022-05-23 09:53:38 +02:00
..
Accounts Allow to tweak default scopes for accounts 2022-05-16 22:54:51 +02:00
Activity Update php licenses 2021-06-04 22:02:41 +02:00
App Keep group restrictions when reenabling apps after an update 2021-10-13 09:34:55 +02:00
AppFramework Make appName of TemplateResponse accessible in BeforeTemplateRenderedEvent 2022-05-20 15:03:40 +02:00
Authentication Specify string as nullable for credentials password 2022-02-28 11:08:48 +01:00
BackgroundJob Allow apps to specify if their background job can be delayed 2022-02-07 13:54:54 +01:00
Broadcast/Events Update php licenses 2021-06-04 22:02:41 +02:00
Calendar Various minor updates 2022-03-02 02:15:05 +00:00
Capabilities Don't inject Bruteforce capability info in the webui 2022-04-07 17:33:29 +02:00
Collaboration Update php licenses 2021-06-04 22:02:41 +02:00
Command Update php licenses 2021-06-04 22:02:41 +02:00
Comments Update ICommentsManager with reaction methods 2022-02-03 12:52:18 -03:00
Console Update php licenses 2021-06-04 22:02:41 +02:00
Contacts Modernize contacts menu 2022-05-12 18:31:59 +02:00
DB tell mysql to ignore the sort index for search queries 2022-04-22 13:42:33 +02:00
Dashboard Fix ArrayAccess and JsonSerializable return types 2021-11-23 09:28:56 +01:00
DataCollector Add a built-in profiler inside Nextcloud 2022-04-04 10:28:26 +02:00
Diagnostics Update php licenses 2021-06-04 22:02:41 +02:00
DirectEditing Add public API for owner based locking 2022-04-04 09:02:56 +02:00
Encryption Migrate HintException to OCP 2021-06-30 15:28:02 -04:00
EventDispatcher Fix ArrayAccess and JsonSerializable return types 2021-11-23 09:28:56 +01:00
Federation Allow to get a local cloud id without going through the contacts manager 2021-07-14 16:08:05 +02:00
Files Make it possible to get the appdata folder using the public API 2022-05-11 23:28:37 +02:00
Files_FullTextSearch/Model Update php licenses 2021-06-04 22:02:41 +02:00
FullTextSearch Fix spelling for return type 2022-05-15 22:03:28 +02:00
GlobalScale Update php licenses 2021-06-04 22:02:41 +02:00
Group Update php licenses 2021-06-04 22:02:41 +02:00
Http Update php licenses 2021-06-04 22:02:41 +02:00
L10N Remove createPluralFunction which is replaced by Symfony\Translations lib 2022-01-24 09:27:01 +01:00
LDAP Fix LDAP related docblocks types 2021-12-16 09:43:31 +01:00
Lock Cleanup lock related code 2022-05-12 15:09:58 +02:00
Lockdown Update php licenses 2021-06-04 22:02:41 +02:00
Log Add a helper function that makes it easier to log from anywhere 2022-05-23 09:53:38 +02:00
Mail fix parameter type hint in phpdoc 2021-09-09 14:03:35 +02:00
Migration Update php licenses 2021-06-04 22:02:41 +02:00
Notification Improve wording 2021-10-27 10:12:30 +02:00
OCS Update php licenses 2021-06-04 22:02:41 +02:00
Preview Update php licenses 2021-06-04 22:02:41 +02:00
Profile Profile backend 2021-10-19 04:59:35 +00:00
Profiler Add a built-in profiler inside Nextcloud 2022-04-04 10:28:26 +02:00
Remote Deprecate OCP\Remote 2021-06-28 16:36:32 +02:00
RichObjectStrings Add talk-poll to the ROS definitions 2022-05-11 14:37:26 +02:00
Route Update php licenses 2021-06-04 22:02:41 +02:00
Search Fix psalm errors fron the end of the baseline file 2022-05-16 10:58:26 +02:00
Security Add an OCP for trusted domain helper 2021-10-28 10:24:16 +02:00
Session/Exceptions Update php licenses 2021-06-04 22:02:41 +02:00
Settings Add admin privilege delegation for admin settings 2021-09-29 21:43:31 +02:00
Share Use email settings in DAV search 2022-04-19 16:23:08 +02:00
Support Fair use of push notifications 2021-10-23 00:54:50 +02:00
SystemTag Update php licenses 2021-06-04 22:02:41 +02:00
Talk Add a Talk API for OCP 2022-02-04 08:53:18 +01:00
User Fetch status in heartbeat controller only once 2022-04-07 15:16:34 +02:00
UserMigration Fix migrators according to exceptions 2022-04-13 16:52:40 +02:00
UserStatus Clarify that some interface are not meant to be implemented 2022-03-04 16:02:35 +01:00
WorkflowEngine Add Psalm specific scope type hint for the WFE operation 2021-11-22 08:42:40 +01:00
App.php Update php licenses 2021-06-04 22:02:41 +02:00
AutoloadNotAllowedException.php Update php licenses 2021-06-04 22:02:41 +02:00
BackgroundJob.php Update php licenses 2021-06-04 22:02:41 +02:00
Constants.php Update php licenses 2021-06-04 22:02:41 +02:00
Defaults.php Merge pull request #26481 from ghost/fdroid 2021-07-13 08:49:59 +02:00
Files.php Update php licenses 2021-06-04 22:02:41 +02:00
GroupInterface.php Update php licenses 2021-06-04 22:02:41 +02:00
HintException.php Migrate HintException to OCP 2021-06-30 15:28:02 -04:00
IAddressBook.php Drop redundanten return comment 2022-05-15 21:57:50 +02:00
IAppConfig.php Update php licenses 2021-06-04 22:02:41 +02:00
IAvatar.php Fix avatar file return type 2022-03-03 15:48:00 +00:00
IAvatarManager.php Update php licenses 2021-06-04 22:02:41 +02:00
ICache.php Add a built-in profiler inside Nextcloud 2022-04-04 10:28:26 +02:00
ICacheFactory.php Update php licenses 2021-06-04 22:02:41 +02:00
ICertificate.php Update php licenses 2021-06-04 22:02:41 +02:00
ICertificateManager.php Update php licenses 2021-06-04 22:02:41 +02:00
IConfig.php Add specific psalm-return for getAllUserValues 2022-01-24 11:16:44 +01:00
IContainer.php Update php licenses 2021-06-04 22:02:41 +02:00
IDBConnection.php Fix spelling for PreConditionNotMetException 2022-05-15 22:05:55 +02:00
IDateTimeFormatter.php Update php licenses 2021-06-04 22:02:41 +02:00
IDateTimeZone.php Update php licenses 2021-06-04 22:02:41 +02:00
IEmojiHelper.php Extract the EmojiService from user status and add an OCP interface 2022-04-28 07:09:44 -03:00
IEventSource.php Update php licenses 2021-06-04 22:02:41 +02:00
IGroup.php Update php licenses 2021-06-04 22:02:41 +02:00
IGroupManager.php Update php licenses 2021-06-04 22:02:41 +02:00
IImage.php Fix typing problems in OC_Image 2021-12-06 14:26:26 +01:00
IInitialStateService.php Update php licenses 2021-06-04 22:02:41 +02:00
IL10N.php Update php licenses 2021-06-04 22:02:41 +02:00
ILogger.php Update php licenses 2021-06-04 22:02:41 +02:00
IMemcache.php Update php licenses 2021-06-04 22:02:41 +02:00
IMemcacheTTL.php Update php licenses 2021-06-04 22:02:41 +02:00
INavigationManager.php Let apps toggle an unread counter on app icons 2021-06-16 17:12:56 +02:00
IPreview.php Move preview provider registration to bootstrap 2021-10-21 10:35:18 +02:00
IRequest.php Update php licenses 2021-06-04 22:02:41 +02:00
IRequestId.php Extract request id handling to dedicated class so it can be injected manually 2022-02-23 11:01:58 +01:00
ISearch.php Update php licenses 2021-06-04 22:02:41 +02:00
IServerContainer.php Add a public replacement for OC::$server->get 2022-05-10 18:51:12 +02:00
ISession.php Update php licenses 2021-06-04 22:02:41 +02:00
IStreamImage.php Send images to imaginary docker to generate previews 2022-03-17 08:24:07 +01:00
ITagManager.php Update php licenses 2021-06-04 22:02:41 +02:00
ITags.php Update php licenses 2021-06-04 22:02:41 +02:00
ITempManager.php Update php licenses 2021-06-04 22:02:41 +02:00
IURLGenerator.php Merge pull request #27733 from PhrozenByte/enhancement/noid/IURLGenerator-linkToDefaultPageUrl 2021-10-05 13:06:59 +02:00
IUser.php enable the user to set a primary (notification) email address (backend) 2021-09-09 19:23:04 +02:00
IUserBackend.php Update php licenses 2021-06-04 22:02:41 +02:00
IUserManager.php enable the user to set a primary (notification) email address (backend) 2021-09-09 19:23:04 +02:00
IUserSession.php Update php licenses 2021-06-04 22:02:41 +02:00
Image.php Update php licenses 2021-06-04 22:02:41 +02:00
PreConditionNotMetException.php Update php licenses 2021-06-04 22:02:41 +02:00
SabrePluginEvent.php Update php licenses 2021-06-04 22:02:41 +02:00
SabrePluginException.php Update php licenses 2021-06-04 22:02:41 +02:00
Server.php Improve psalm annotation to make it stricter 2022-05-13 16:14:01 +02:00
Share.php Fix psalm errors fron the end of the baseline file 2022-05-16 10:58:26 +02:00
Share_Backend.php Update php licenses 2021-06-04 22:02:41 +02:00
Share_Backend_Collection.php Update php licenses 2021-06-04 22:02:41 +02:00
Share_Backend_File_Dependent.php Update php licenses 2021-06-04 22:02:41 +02:00
Template.php Update php licenses 2021-06-04 22:02:41 +02:00
UserInterface.php Update php licenses 2021-06-04 22:02:41 +02:00
Util.php Fix psalm errors fron the end of the baseline file 2022-05-16 10:58:26 +02:00