{"id":19450861,"url":"https://github.com/morning-train/wp-logger","last_synced_at":"2025-10-22T03:00:13.840Z","repository":{"id":160889537,"uuid":"635686669","full_name":"Morning-Train/wp-logger","owner":"Morning-Train","description":"WordPress Logger","archived":false,"fork":false,"pushed_at":"2023-06-08T11:49:18.000Z","size":36,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-08T11:13:34.656Z","etag":null,"topics":[],"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/Morning-Train.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-03T08:35:12.000Z","updated_at":"2023-05-03T08:38:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"5ddd6bac-c9bc-4251-8ecf-e8e099573fa4","html_url":"https://github.com/Morning-Train/wp-logger","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morning-Train%2Fwp-logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morning-Train%2Fwp-logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morning-Train%2Fwp-logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morning-Train%2Fwp-logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Morning-Train","download_url":"https://codeload.github.com/Morning-Train/wp-logger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240637766,"owners_count":19833189,"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":[],"created_at":"2024-11-10T16:39:18.876Z","updated_at":"2025-10-22T03:00:08.773Z","avatar_url":"https://github.com/Morning-Train.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WP Logger\n\nMake it easier to handle different levels of log.\n\n\n## Table of Contents\n\n- [Introduction](#introduction)\n- [Getting Started](#getting-started)\n  - [Installation](#installation)\n- [Dependencies](#dependencies)\n- [Usage](#usage)\n  - [Initializing package](#initializing-package)\n  - [Use package](#use-package)\n- [Contributing](#contributing)\n- [Contributors](#contributors)\n- [License](#license)\n\n\n## Introduction\n\nMake it easier to handle different levels of log.\n\n\n## Getting Started\n\nTo get started install the package as described below in [Installation](#installation).\n\nTo use the tool have a look at [Usage](#usage)\n\n\n### Installation\n\nInstall with composer\n\n```bash\ncomposer require morningtrain/wp-logger\n```\n\n\n## Dependencies\n\n- [psr/log](https://packagist.org/packages/psr/log)\n\n\n## Usage\n\n### Initializing package\n\nFirst of all, to get `\\Morningtrain\\WP\\Logger\\Loggers\\DatabaseLogger` to work, the migration needs to be run. This is done be running the following method:  \n\n```php\n\\Morningtrain\\WP\\Logger\\Logger::initializeMigration()\n```\n\nInitialize `\\Morningtrain\\WP\\Logger\\Logger` with a slug and an array of the loggers that needs to be registered.  \nFor each logger, there is some levels, that can be registered for the specific logger.\n\n```php\n\\Morningtrain\\WP\\Logger\\Logger::registerLoggers(\n    'logger', \n    [\n        // Loggers\n    ]\n);\n```\n\n#### Loggers\nEach logger has the following methods, to register what level(s) that is needed:  \n- `-\u003eregisterLevel($level)`\n- `-\u003eregisterLevels([$level])`\n- `-\u003eregisterAllLevels()`\n\n##### _Database Logger_  \nMake it possible to save logs to the database.  \nClass: `\\Morningtrain\\WP\\Logger\\Loggers\\DatabaseLogger`\n\n```php\n\\Morningtrain\\WP\\Logger\\Logger::databaseLogger()\n```\n\n##### _File Logger_  \nMake it possible to save logs to a file.  \nClass: `\\Morningtrain\\WP\\Logger\\Loggers\\FileLogger`\nParameters in callback:\n- `string $filename`\n\n```php\n\\Morningtrain\\WP\\Logger\\Logger::fileLogger($filename)\n```\n\n##### _Mail Logger_  \nMake it possible to send logs to multiple emails.  \nClass: `\\Morningtrain\\WP\\Logger\\Loggers\\MailLogger`\nParameters in callback:\n- `array $emails`\n\n```php\n\\Morningtrain\\WP\\Logger\\Logger::mailLogger($emails)\n```\n\n##### _Ray Logger_\nMake it possible to send logs to a Ray client.  \nClass: `\\Morningtrain\\WP\\Logger\\Loggers\\RayLogger`\nParameters in callback:\n- `bool $backtrace // Optional. If true, it will add backtrace`\n\n```php\n\\Morningtrain\\WP\\Logger\\Logger::rayLogger()\n```\n\n#### Levels\n```php\n\\Psr\\Log\\LogLevel::EMERGENCY\n\\Psr\\Log\\LogLevel::ALERT\n\\Psr\\Log\\LogLevel::CRITICAL\n\\Psr\\Log\\LogLevel::ERROR\n\\Psr\\Log\\LogLevel::WARNING\n\\Psr\\Log\\LogLevel::NOTICE\n\\Psr\\Log\\LogLevel::INFO\n\\Psr\\Log\\LogLevel::DEBUG\n```\n\n### Use package\n\nTo get the Logger, that has been registered, the method `\\Morningtrain\\WP\\Logger\\Logger::getLogger($slug)`, where the slug is needed.  \nWhen the logger is collected, there is a method, for each level, that can be call:\n\n```php\n\\Morningtrain\\WP\\Logger\\Logger::getLogger('logger')\n    -\u003eemergency()\n    -\u003ealert()\n    -\u003ecritical()\n    -\u003eerror()\n    -\u003ewarning()\n    -\u003enotice()\n    -\u003einfo()\n    -\u003edebug()\n```\n\nEach of these methods that:\n- `string $message`\n- `array $context // Optional`\n\n\n## Contributing\n\nThank you for your interest in contributing to the project.\n\n\n### Bug Report\n\nIf you found a bug, we encourage you to make a pull request.\n\nTo add a bug report, create a new issue. Please remember to add a telling title, detailed description and how to reproduce the problem.\n\n\n### Support Questions\n\nWe do not provide support for this package.\n\n\n### Pull Requests\n\n1. Fork the Project\n2. Create your Feature Branch (git checkout -b feature/AmazingFeature)\n3. Commit your Changes (git commit -m 'Add some AmazingFeature')\n4. Push to the Branch (git push origin feature/AmazingFeature)\n5. Open a Pull Request\n\n\n## Contributors\n\n- [Martin Schadegg Brønniche](https://github.com/mschadegg)\n- [Mathias Bærentsen](https://github.com/matbaek)\n- [All Contributors](../../contributors)\n\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE) for more information.\n\n\n---\n\n\u003cdiv align=\"center\"\u003e\nDeveloped by \u003cbr\u003e\n\u003c/div\u003e\n\u003cbr\u003e\n\u003cdiv align=\"center\"\u003e\n\u003ca href=\"https://morningtrain.dk\" target=\"_blank\"\u003e\n\u003cimg src=\"https://morningtrain.dk/wp-content/themes/mtt-wordpress-theme/assets/img/logo-only-text.svg\" width=\"200\" alt=\"Morningtrain logo\"\u003e\n\u003c/a\u003e\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorning-train%2Fwp-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmorning-train%2Fwp-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorning-train%2Fwp-logger/lists"}