{"id":19144370,"url":"https://github.com/piotrpress/logger","last_synced_at":"2025-05-07T01:10:20.681Z","repository":{"id":57041815,"uuid":"350853839","full_name":"PiotrPress/logger","owner":"PiotrPress","description":"This library is compatible with PSR-3 file logger implementation.","archived":false,"fork":false,"pushed_at":"2024-09-15T20:19:55.000Z","size":18,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-19T17:16:37.276Z","etag":null,"topics":["error-logger","file-logger","logger","logging","logging-to-file","logs","php","php-logging-library","psr-3","psr3"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PiotrPress.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","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":"2021-03-23T20:50:50.000Z","updated_at":"2024-11-28T17:14:14.000Z","dependencies_parsed_at":"2024-11-09T07:46:48.130Z","dependency_job_id":null,"html_url":"https://github.com/PiotrPress/logger","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PiotrPress%2Flogger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PiotrPress%2Flogger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PiotrPress%2Flogger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PiotrPress%2Flogger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PiotrPress","download_url":"https://codeload.github.com/PiotrPress/logger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252793651,"owners_count":21805058,"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":["error-logger","file-logger","logger","logging","logging-to-file","logs","php","php-logging-library","psr-3","psr3"],"created_at":"2024-11-09T07:34:40.673Z","updated_at":"2025-05-07T01:10:20.661Z","avatar_url":"https://github.com/PiotrPress.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Logger\n\nThis library is compatible with [PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md) file logger implementation.\n\n## Installation\n\n```console\ncomposer require piotrpress/logger\n```\n\n## Example\n\n```php\nrequire __DIR__ . '/vendor/autoload.php';\n\nuse PiotrPress\\Logger;\nuse PiotrPress\\Logger\\FileHandler;\nuse PiotrPress\\Logger\\ErrorLogHandler;\n\n$logger = new Logger(\n    new FileHandler( __DIR__ . '/' . date( 'Y-m-d' ) . '.log' ),\n    new ErrorLogHandler() \n);\n    \n$logger-\u003eerror( '[{module}] Example error', [ 'module' =\u003e 'Core' ] );\n```\n\nSaves: `[error] [Core] Example error` to file: `{Y-m-d}.log` and sends to PHP error log.\n\n## Logger\n\n[Logger](/src/Logger.php) take any number of handlers implementing [HandlerInterface](/src/Handler/HandlerInterface.php) as constructor arguments.\n\n## Handlers\n\n- [ErrorLogHandler](/src/Handler/ErrorLogHandler.php) - send logs to PHP error log.\n- [FileHandler](/src/Handler/FileHandler.php) - send logs to file.\n\n**NOTE:** Both handlers support optional [FormatterInterface](/src/Formatter/FormatterInterface.php) parameter. \n\n## Formatters\n\n- [ErrorLogFormatter](/src/Formatter/ErrorLogFormatter.php) - formats [LogRecord](/src/LogRecord.php) using [error_log](/tpl/error_log.php) template.\n- [FileFormatter](/src/Formatter/FileFormatter.php) - formats [LogRecord](/src/LogRecord.php) using [file](/tpl/file.php) template.\n\n**NOTE:** Both formatters support optional path to `template` parameter.\n\n## Levels\n\nLogger supports eight log methods to write logs to the eight [RFC 5424](http://tools.ietf.org/html/rfc5424) levels (`debug`, `info`, `notice`, `warning`, `error`, `critical`, `alert`, `emergency`) and a ninth method `log`, which accepts a log level as the first argument.\n\n## Context\n\nAll Logger log methods supports optional `context` array parameter.\n\nAll additional `context` array values, evaluated to string, can be used in `message` via corresponding keys put between a single opening brace `{` and a single closing brace `}` according to [PSR-3](https://www.php-fig.org/psr/psr-3/#13-context) guidelines.\n\nContext values can be also used in `templates` files as regular PHP variables.\n\n## Requirements\n\nSupports PHP \u003e= `7.4` version.\n\n## License\n\n[GPL3.0](license.txt)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiotrpress%2Flogger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpiotrpress%2Flogger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiotrpress%2Flogger/lists"}