{"id":19289816,"url":"https://github.com/brefphp/logger","last_synced_at":"2025-04-22T05:31:50.860Z","repository":{"id":34273638,"uuid":"174233990","full_name":"brefphp/logger","owner":"brefphp","description":"All you need to log with Bref on AWS Lambda.","archived":false,"fork":false,"pushed_at":"2023-06-07T12:45:17.000Z","size":18,"stargazers_count":34,"open_issues_count":4,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-15T20:22:19.016Z","etag":null,"topics":["aws-lambda","bref","logger","psr-3","serverless"],"latest_commit_sha":null,"homepage":"https://bref.sh/docs/environment/logs.html","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/brefphp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","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},"funding":{"github":"mnapoli","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2019-03-06T22:59:05.000Z","updated_at":"2025-01-03T12:50:09.000Z","dependencies_parsed_at":"2024-06-18T18:22:52.542Z","dependency_job_id":"6ded54e1-cf7c-4512-941a-a827695e28d6","html_url":"https://github.com/brefphp/logger","commit_stats":{"total_commits":16,"total_committers":3,"mean_commits":5.333333333333333,"dds":0.125,"last_synced_commit":"76710c21a58a939fef23a482aaeacfd23170579b"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brefphp%2Flogger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brefphp%2Flogger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brefphp%2Flogger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brefphp%2Flogger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brefphp","download_url":"https://codeload.github.com/brefphp/logger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250175068,"owners_count":21387132,"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":["aws-lambda","bref","logger","psr-3","serverless"],"created_at":"2024-11-09T22:17:17.557Z","updated_at":"2025-04-22T05:31:50.627Z","avatar_url":"https://github.com/brefphp.png","language":"PHP","readme":"All you need to log with [Bref](https://bref.sh) on AWS Lambda.\n\n[![Build Status](https://img.shields.io/travis/brefphp/logger/master.svg?style=flat-square)](https://travis-ci.com/brefphp/logger)\n[![Latest Version](https://img.shields.io/github/release/brefphp/logger.svg?style=flat-square)](https://packagist.org/packages/bref/logger)\n\nBref/Logger is a lightweight [PSR-3](https://www.php-fig.org/psr/psr-3/) logger for AWS Lambda. Messages are sent to `stderr` so that they end up in [CloudWatch](https://bref.sh/docs/environment/logs.html).\n\n## Why?\n\nAs explained in [the Bref documentation](https://bref.sh/docs/environment/logs.html), logging in AWS Lambda means logging to `stderr`. Logs written to `stderr` are automatically sent to [CloudWatch](https://aws.amazon.com/cloudwatch/), AWS' solution to collect and view logs.\n\nWhile classic loggers like [Monolog](https://github.com/Seldaek/monolog) work fine, this logger comes as a simpler and lighter alternative optimized for AWS Lambda. It does not require any configuration and currently contains a single class.\n\nSince it is [PSR-3](https://www.php-fig.org/psr/psr-3/) compliant, Bref/Logger is also compatible with any framework or library consuming a PSR-3 logger.\n\n## Installation\n\n```\ncomposer require bref/logger\n```\n\n## Usage\n\nThe logger does not require any configuration:\n\n```php\n$logger = new \\Bref\\Logger\\StderrLogger();\n```\n\nBy default messages **above the `warning` level** will be logged, the rest will be discarded.\n\nIt is possible to log using any [PSR-3 log level](https://www.php-fig.org/psr/psr-3/#5-psrlogloglevel), the most common ones being:\n\n```php\n$logger-\u003edebug('This is a debug message');\n$logger-\u003einfo('This is an info');\n$logger-\u003ewarning('This is a warning');\n$logger-\u003eerror('This is an error');\n```\n\n```\n[WARNING] This is a warning\n[ERROR] This is an error\n```\n\nMessages under `warning` are not logged.\n\n### Message placeholders\n\n[PSR-3 placeholders](https://www.php-fig.org/psr/psr-3/#12-message) can be used to insert information from the `$context` array into the message without having to concatenate strings manually:\n\n```php\n$logger-\u003ewarning('Invalid login attempt for email {email}', [\n    'email' =\u003e $email,\n]);\n```\n\n```\n[WARNING] Invalid login attempt for email johndoe@example.com\n```\n\n### Logging exceptions\n\nExceptions [can be logged](https://www.php-fig.org/psr/psr-3/#13-context) under the `exception` key:\n\n```php\ntry {\n   // ...\n} catch (\\Exception $e) {\n    $logger-\u003eerror('Impossible to complete the action', [\n        'exception' =\u003e $e,\n    ]);\n}\n```\n\n```\n[ERROR] Impossible to complete the action\nInvalidArgumentException: Impossible to complete the action in /var/task/index.php:12\nStack trace:\n#0 /var/task/index.php(86): main()\n...\n```\n\n### Log level\n\nIt is possible to change the level above which messages are logged.\n\nFor example to log all messages:\n\n```php\n$logger = new \\Bref\\Logger\\StderrLogger(\\Psr\\Log\\LogLevel::DEBUG);\n```\n","funding_links":["https://github.com/sponsors/mnapoli"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrefphp%2Flogger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrefphp%2Flogger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrefphp%2Flogger/lists"}