{"id":13616243,"url":"https://github.com/alexandre-daubois/monolog-processor-collection","last_synced_at":"2025-04-01T16:48:44.612Z","repository":{"id":205799738,"uuid":"715130038","full_name":"alexandre-daubois/monolog-processor-collection","owner":"alexandre-daubois","description":"A collection of Monolog processors","archived":false,"fork":false,"pushed_at":"2023-12-23T17:56:35.000Z","size":54,"stargazers_count":15,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T06:53:33.220Z","etag":null,"topics":["log","logger","logging","monolog","monolog-processor","psr-3","psr3"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/alexandre-daubois/monolog-processor-collection","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/alexandre-daubois.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-11-06T14:36:55.000Z","updated_at":"2024-08-21T16:23:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"5f3d7e06-81ed-42f9-b8da-dffef0285538","html_url":"https://github.com/alexandre-daubois/monolog-processor-collection","commit_stats":null,"previous_names":["alexandre-daubois/monolog-processor-collection"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexandre-daubois%2Fmonolog-processor-collection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexandre-daubois%2Fmonolog-processor-collection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexandre-daubois%2Fmonolog-processor-collection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexandre-daubois%2Fmonolog-processor-collection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexandre-daubois","download_url":"https://codeload.github.com/alexandre-daubois/monolog-processor-collection/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246674101,"owners_count":20815681,"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":["log","logger","logging","monolog","monolog-processor","psr-3","psr3"],"created_at":"2024-08-01T20:01:25.746Z","updated_at":"2025-04-01T16:48:44.592Z","avatar_url":"https://github.com/alexandre-daubois.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# Monolog Processor Collection\n\n[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%208.1-8892BF.svg?style=flat-square)](https://php.net/)\n![CI](https://github.com/alexandre-daubois/monolog-processor-collection/actions/workflows/php.yml/badge.svg)\n[![Latest Stable Version](http://poser.pugx.org/alexandre-daubois/monolog-processor-collection/v/stable)](https://packagist.org/packages/alexandre-daubois/monolog-processor-collection)\n[![License](http://poser.pugx.org/alexandre-daubois/monolog-processor-collection/license)](https://packagist.org/packages/alexandre-daubois/monolog-processor-collection)\n\nWelcome to the Monolog Processor Collection (MPC) - the ultimate suite of processors designed to enhance your logging\nwith the renowned [Monolog](https://github.com/Seldaek/monolog) library. This toolkit is meticulously crafted to\nintegrate seamlessly with PHP 8.1+, ensuring your logging captures the comprehensive details you need with minimal\noverhead.\n\nMPC is engineered for developers who demand more from their logs. Whether you're tracking down elusive bugs or\nmonitoring live production environments, processors enrich your log entries with invaluable context, turning\nordinary logs into a rich, actionable dataset.\n\nMPC is compatible with worker mode of web servers, as relevant processors implement the `ResettableInterface`.\n\n## Available Processors\n\nThe package provides the following processors:\n\n- `BacktraceProcessor` adds the backtrace to the log record\n- `ClientIpProcessor` adds the client IP address to the log record\n- `EnvVarProcessor` adds the value of one or more environment variables to the log record\n- `HighResolutionTimestampProcessor` adds the high resolution time to the log record\n- `IsHttpsProcessor` adds a boolean value indicating whether the request is a secured HTTP request to the log record\n- `PhpIniValueProcessor` adds the value of one or more PHP ini settings to the log record\n- `ProtocolVersionProcessor` adds the HTTP protocol version to the log record\n- `RequestSizeProcessor` adds the size of the request to the log record, headers included, in bytes\n- `ResourceUsagesProcessor` adds the resource usage to the log record as returned by [getrusage()](https://www.php.net/manual/en/function.getrusage.php)\n- `SapiNameProcessor` adds the name of the SAPI to the log record\n- `SessionIdProcessor` adds the session ID to the log record, or null if no session is active\n- `UuidProcessor` adds a UUID v7 to the log record to track records triggered during the same request\n\n## Installation\n\nThe recommended way to install MPC is through [Composer](https://getcomposer.org/):\n\n```bash\ncomposer require alexandre-daubois/monolog-processor-collection\n```\n\n## Usage\n\nAll processor can be used in the same way as any other Monolog processor. For example:\n\n```php\nuse Monolog\\Logger;\n\n$logger = new Logger('name');\n$logger-\u003epushProcessor(new BacktraceProcessor());\n```\n\nSome processors, like `EnvVarProcessor` and `PhpIniValueProcessor`, require you to specify more\narguments. For example:\n\n```php\nuse Monolog\\Logger;\n\n$logger = new Logger('name');\n$logger-\u003epushProcessor(new EnvVarProcessor(['APP_ENV', 'APP_DEBUG']));\n```\n\n## Integration with Symfony and MonologBundle\n\nYou can register those processors to be used with Symfony and MonologBundle by adding the following configuration to\nyour `config/packages/monolog.php` file:\n\n```php\nuse Monolog\\Processor\\ProcessorInterface;\nuse MonologProcessorCollection\\BacktraceProcessor;\nuse MonologProcessorCollection\\EnvVarProcessor;\nuse MonologProcessorCollection\\ProtocolVersionProcessor;\nuse MonologProcessorCollection\\EnvVarProcessor;\nuse MonologProcessorCollection\\SapiNameProcessor;\n\nreturn static function (ContainerConfigurator $configurator): void {\n    // ...\n\n    // register as many processors as you like, but keep in mind that\n    // each processor is called for each log record\n    $services = $configurator-\u003eservices();\n    $services\n        -\u003eset(BacktraceProcessor::class)\n        -\u003eset(EnvVarProcessor::class)-\u003eargs(['APP_ENV'])\n        -\u003eset(ProtocolVersionProcessor::class)\n        -\u003eset(SapiNameProcessor::class);\n\n    // ...\n};\n```\n\nIf you don't use autoconfigure, you need to tag the processors with `monolog.processor`:\n\n```php\nreturn static function (ContainerConfigurator $configurator): void {\n    // ...\n\n    $services = $configurator-\u003eservices();\n    $services\n        -\u003eset(BacktraceProcessorAlias::class)\n            -\u003etag('monolog.processor', ['handler' =\u003e 'main'])\n        -\u003eset(EnvVarProcessor::class)-\u003eargs(['APP_ENV'])\n            -\u003etag('monolog.processor', ['handler' =\u003e 'main']);\n\n    // ...\n};\n```\n\nYou can achieve the same configuration with YAML:\n\n```yaml\n# config/packages/monolog.yaml\nservices:\n    MonologProcessorCollection\\BacktraceProcessor:\n        tags:\n            - { name: monolog.processor, handler: main }\n    MonologProcessorCollection\\EnvVarProcessor:\n        arguments:\n            - APP_ENV\n        tags:\n            - { name: monolog.processor, handler: main }\n```\n\nOr XML:\n\n```xml\n\u003c!-- config/packages/monolog.xml --\u003e\n\n\u003c!-- ... --\u003e\n\n\u003cservice id=\"MonologProcessorCollection\\BacktraceProcessor\" public=\"false\"\u003e\n    \u003ctag name=\"monolog.processor\" handler=\"main\" /\u003e\n\u003c/service\u003e\n\u003cservice id=\"MonologProcessorCollection\\EnvVarProcessor\" public=\"false\"\u003e\n    \u003cargument\u003eAPP_ENV\u003c/argument\u003e\n    \u003ctag name=\"monolog.processor\" handler=\"main\" /\u003e\n\u003c/service\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexandre-daubois%2Fmonolog-processor-collection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexandre-daubois%2Fmonolog-processor-collection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexandre-daubois%2Fmonolog-processor-collection/lists"}