{"id":19196957,"url":"https://github.com/jitesoft/wp-logger","last_synced_at":"2026-05-12T12:39:47.321Z","repository":{"id":56999420,"uuid":"396475040","full_name":"jitesoft/wp-logger","owner":"jitesoft","description":"An actual logger for WordPress.","archived":false,"fork":false,"pushed_at":"2022-08-15T19:45:21.000Z","size":56,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-04T10:08:26.070Z","etag":null,"topics":["hacktoberfest","logger","logging","php","wordpress","wordpress-plugin"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jitesoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-08-15T19:53:02.000Z","updated_at":"2022-08-15T19:45:23.000Z","dependencies_parsed_at":"2022-08-21T11:40:41.009Z","dependency_job_id":null,"html_url":"https://github.com/jitesoft/wp-logger","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jitesoft%2Fwp-logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jitesoft%2Fwp-logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jitesoft%2Fwp-logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jitesoft%2Fwp-logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jitesoft","download_url":"https://codeload.github.com/jitesoft/wp-logger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240271531,"owners_count":19774859,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","logger","logging","php","wordpress","wordpress-plugin"],"created_at":"2024-11-09T12:15:00.983Z","updated_at":"2026-05-12T12:39:42.300Z","avatar_url":"https://github.com/jitesoft.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Wp-logger\n\n## An actual logger for WordPress.\n\nThis plugin does two things. It piggybacks on the internal php logger (via `set_error_handler`) and \nit creates a PSR logger for you to use!\n\n### More in-depth\n\nWhen the plugin have loaded completely in WordPress, it will fire the `jitesoft_logger_loaded` action,\nthe callback will be passed the global logger object.  \nIf you _know_ that the plugin is loaded, you can as well use the `jitesoft('logger')` function to request the logger\ninstance. In case it is not yet loaded, the function will return null:\n\n```php \n$logger = jitesoft('logger'); // null if not lodaed\nadd_action('jitesoft_logger_loaded', static fn($logger) =\u003e $logger); // will not be null when loaded.\n```\n\n_Deprecation notice, the following will be removed in next major version_\n\nIt's also possible to fetch the logger through the `GlobalLogger` class through the `logger()` method:\n\n```php \nJitesoft\\WordPress\\Plugins\\Logger\\GlobalLogger;\n\n$logger = GlobalLogger::logger();\n```\n\n### Auto-loading\n\nThe plugin requires auto-loading to function properly. Without the autoloader, the plugin won't be able to find\nthe libraries it uses and hence will not create a logger.\n\n## Configuring\n\nThe plugin is currently configured via environment variables or defines. The values must be\ndefined _before_ loading the plugin, so the wp-config.php file or actual environment variables are preferable\nplaces to put those.\n\n`WP_LOGGER_OVERRIDE` is default set to override, can be changed to `disable` to _not_ override the internal\nphp logger.  \n  \n`WP_ENV` sets the default logging level on the logger:\n\n  * `production`: errors and above\n  * `staging`: info and above\n  * `development`: debug and above\n\nIn case you wish to change the logging level manually, you can set the `WP_LOGGER_LEVEL` to an appropriate level,\nthe following are accepted: `debug`, `notice`, `info`, `warning`, `error`, `critical`, `alert`, `emergency`.\n\nYou can also change the log level by fireing the `jitesoft_log_level` hook with a single string parameter\nwith a value of the above log levels.\n\n### Formatting\n\nCurrently, the logger supports two default types: `json`, `stdout`.   \nThey are possible to set with the `WP_LOGGER_FORMAT` variable (`stdout` is default).  \nBoth of the types will output to the stdout/stderr channel (the terminal) while they \nwill produce either clear text logs or json formatted logs.  \n  \nIf you wish to change the loggers on the logging object, it's possible to do so by querying the logger and\nadd (or remove) loggers from it. Multiple loggers can be added:\n\n```php \njitesoft('logger')-\u003eremoveLogger('stdout');\njitesoft('logger')-\u003eremoveLogger('json');\n\njitesoft('logger')-\u003eaddLogger(new MyPsrLogger(), 'myLogger');\n```\n\nOr directly in the hook:\n\n```php \nadd_action('jitesoft_logger_loaded', static function($logger) {\n    $logger-\u003eremoveLogger('stdout');\n    $logger-\u003eremoveLogger('json');\n    $logger-\u003eaddLogger(new MyPsrLogger(), 'myLogger');\n});\n```\n\n## Installation\n\nUse a composer based WordPress installation and require this plugin.  \n\n## Loggers\n\nIf you wish to add more loggers, the package depends on the [`jitesoft/loggers`](https://packagist.org/packages/jitesoft/loggers)\nphp package, which contains multiple different loggers.  \nIf you wish to use your own loggers, the logger must implement the [PSR-3 logger](https://www.php-fig.org/psr/psr-3/) interface.\n\n## License\n\nMIT!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjitesoft%2Fwp-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjitesoft%2Fwp-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjitesoft%2Fwp-logger/lists"}