{"id":36971648,"url":"https://github.com/tomphp/php-context-logger","last_synced_at":"2026-01-13T21:54:29.444Z","repository":{"id":57071491,"uuid":"74296475","full_name":"tomphp/php-context-logger","owner":"tomphp","description":"A PSR-3 compliant logger decorator which allows context metadata to be built up.","archived":false,"fork":false,"pushed_at":"2016-11-24T11:32:46.000Z","size":25,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-27T02:46:56.417Z","etag":null,"topics":["logging","php","psr3"],"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/tomphp.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2016-11-20T19:12:52.000Z","updated_at":"2022-05-06T18:08:40.000Z","dependencies_parsed_at":"2022-08-24T14:54:27.904Z","dependency_job_id":null,"html_url":"https://github.com/tomphp/php-context-logger","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/tomphp/php-context-logger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomphp%2Fphp-context-logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomphp%2Fphp-context-logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomphp%2Fphp-context-logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomphp%2Fphp-context-logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tomphp","download_url":"https://codeload.github.com/tomphp/php-context-logger/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomphp%2Fphp-context-logger/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28401537,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["logging","php","psr3"],"created_at":"2026-01-13T21:54:27.479Z","updated_at":"2026-01-13T21:54:29.437Z","avatar_url":"https://github.com/tomphp.png","language":"PHP","readme":"# Context Logger\n\n[![Build Status](https://travis-ci.org/tomphp/php-context-logger.svg?branch=master)](https://travis-ci.org/tomphp/php-context-logger)\n[![Latest Stable Version](https://poser.pugx.org/tomphp/context-logger/v/stable)](https://packagist.org/packages/tomphp/context-logger)\n[![Total Downloads](https://poser.pugx.org/tomphp/context-logger/downloads)](https://packagist.org/packages/tomphp/context-logger)\n[![Latest Unstable Version](https://poser.pugx.org/tomphp/context-logger/v/unstable)](https://packagist.org/packages/tomphp/context-logger)\n[![License](https://poser.pugx.org/tomphp/context-logger/license)](https://packagist.org/packages/tomphp/context-logger)\n\nA PSR-3 compliant logger decorator which allows context metadata to be built up.\n\n## Installation\n\n```\n$ composer require tomphp/context-logger\n```\n\n## Usage\n\n```php\n\u003c?php\n\nuse Monolog\\Logger;\nuse Monolog\\Handler\\StreamHandler;\nuse TomPHP\\ContextLogger;\n\n$monolog = new Logger('name');\n$monolog-\u003epushHandler(new StreamHandler('path/to/your.log', Logger::WARNING));\n\n$log = new ContextLogger($monolog);\n\n$log-\u003eaddContext('correlation_id', uniqid());\n\n$log-\u003eerror('There was an error');\n```\n\n### Setting the Context\n\nAn original context can be set by providing an array as the second argument to\nthe constructor:\n\n```php\n$log = new ContextLogger($monolog, ['correlation_id' =\u003e uniqid()]);\n```\n\nThe context can be added to or modified by the\n`addContext(string $name, $value)` method.\n\nThe context can also be added to/modified by providing an array to the\n`$context` parameter of any of the PSR-3 `LoggerInterface` methods.\n\n### Removing Context\n\nYou can remove a item from the context by using the `removeContext(string $name)`\nmethod.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomphp%2Fphp-context-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomphp%2Fphp-context-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomphp%2Fphp-context-logger/lists"}