{"id":21418485,"url":"https://github.com/itafroma/snaglogger","last_synced_at":"2025-07-14T05:31:06.651Z","repository":{"id":15262869,"uuid":"77794950","full_name":"itafroma/snaglogger","owner":"itafroma","description":"A PSR-3 logger for Bugsnag","archived":false,"fork":false,"pushed_at":"2021-10-30T08:56:27.000Z","size":47,"stargazers_count":1,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-26T21:52:58.051Z","etag":null,"topics":["bugsnag","logging","psr-3"],"latest_commit_sha":null,"homepage":"","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/itafroma.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-01T20:17:23.000Z","updated_at":"2022-10-29T08:08:08.000Z","dependencies_parsed_at":"2022-07-20T21:32:13.184Z","dependency_job_id":null,"html_url":"https://github.com/itafroma/snaglogger","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/itafroma/snaglogger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itafroma%2Fsnaglogger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itafroma%2Fsnaglogger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itafroma%2Fsnaglogger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itafroma%2Fsnaglogger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/itafroma","download_url":"https://codeload.github.com/itafroma/snaglogger/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itafroma%2Fsnaglogger/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265245950,"owners_count":23734108,"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":["bugsnag","logging","psr-3"],"created_at":"2024-11-22T19:21:43.371Z","updated_at":"2025-07-14T05:31:06.364Z","avatar_url":"https://github.com/itafroma.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Snaglogger\n\nSnaglogger is a PSR-3-compatible logger that sends log messages to [Bugsnag](https://bugsnag.com).\n\n## Installation\n\nSnaglogger can be added to your project via [Composer](https://getcomposer.org):\n\n```json\n{\n    \"require\": {\n        \"itafroma/snaglogger\": \"^2.0\"\n    }\n}\n```\n\nSnaglogger uses [semantic versioning](http://semver.org). In general, you can pin to `^[MAJOR].0` and be confident you will not receive breaking changes during updates.\n\n## Usage\n\n### Quickstart\n\nSnaglogger comes with a factory that instantiates the logger with sensible defaults:\n\n```php\nuse Itafroma\\Snaglogger\\LoggerFactory;\n\n$key    = 'YOUR BUGSNAG API KEY HERE';\n$logger = LoggerFactory::create($key);\n```\n\nOnce instantiated, the logger will work as any other PSR-3-compatiable logger:\n\n```php\n$logger-\u003einfo('This is an informational message.');\n$logger-\u003eerror('This is an error.');\n```\n\n### The PSR-3 context array\n\nSnaglogger will send the contents of the `$context` array to Bugsnag as [metadata](https://docs.bugsnag.com/platforms/php/other/#custom-diagnostics).\n\nAdditionally, Snaglogger treats two `$context` keys as special:\n\n- If the `exception` key contains an instance of an exception, Snaglogger will record the log message as an exception instead of an error.\n- If the `error-type` key is set, Snaglogger will use that as the error type. Otherwise, it will use the error severity.\n\nFinally, Snaglogger will use the `$context` array for placeholder replacement within the log message:\n\n```php\n$message = 'The {location} is on fire!';\n$context = ['location' =\u003e 'roof'];\n\n// Bugsnag will record the error message as \"The roof is on fire!\"\n$logger-\u003eerror($message, $context);\n```\n\n### Severity levels\n\nBugsnag only supports three severity levels: info, warning, and error. However, PSR-3 requires loggers to support eight: emergency, alert, critical, error, warning, notice, info, and debug. By default, Snaglogger maps these additional log levels to the closest Bugsnag severity level:\n\n- emergency → error\n- alert → error\n- critical → error\n- error → error\n- warning → warning\n- notice → info\n- info → info\n- debug → info\n\n### Advanced usage\n\nSome functionality can be customized by implementing certain interfaces:\n\n- Custom severity mapping: [`\\Itafroma\\Snaglogger\\SeverityMapperInterface`](./src/SeverityMapperInterface.php)\n- Custom message interpolation: [`\\Itafroma\\Snaglogger\\MessageInterpolatorInterface`](./src/MessageInterpolatorInterface.php)\n\nMore information can be found in those interfaces' inline documentation.\n\nYou may also want to [customize the Bugsnag client](https://docs.bugsnag.com/platforms/php/other/configuration-options/).\n\nTo override Snaglogger's default functionality, you will need to:\n\n1. Implement your own concrete class of [`\\Itafroma\\Snaglogger\\LoggerFactoryInterface`](./src/LoggerFactoryInterface.php), and/or\n2. Call the `Logger` constructor directly.\n\nFor example:\n\n```php\n$client = Client::make('API KEY')-\u003esetReleaseStage('prod');\n$interpolator = new CustomMessageInterpolator();\n$mapper = new CustomSeverityMapper();\n\n$logger = new Logger($client, $interpolator, $mapper);\n```\n\n## Contributing\n\nContributions are welcome! Please see the separate [CONTRIBUTING](./CONTRIBUTING.md) file for more information.\n\n## Copyright and license\n\nThis extension is copyright [Mark Trapp](https://marktrapp.com). All Rights Reserved. It is made available under the terms of the MIT license. A copy of the license can be found in the [LICENSE](./LICENSE) file.\n\n## Disclaimer\n\nThis project has no affliation with Bugsnag in any way. Additional disclaimers can be found in the [LICENSE](./LICENSE) file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitafroma%2Fsnaglogger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitafroma%2Fsnaglogger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitafroma%2Fsnaglogger/lists"}