{"id":21948431,"url":"https://github.com/devuri/logger","last_synced_at":"2026-01-24T17:32:51.405Z","repository":{"id":257825308,"uuid":"872221032","full_name":"devuri/logger","owner":"devuri","description":null,"archived":false,"fork":false,"pushed_at":"2024-10-14T04:49:08.000Z","size":33,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T20:22:47.909Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/devuri.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":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-14T03:51:39.000Z","updated_at":"2024-10-14T04:49:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"afb2f71f-ed63-4ec4-ba2e-d917768b703b","html_url":"https://github.com/devuri/logger","commit_stats":null,"previous_names":["devuri/logger"],"tags_count":1,"template":false,"template_full_name":"devuri/dot-access","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devuri%2Flogger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devuri%2Flogger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devuri%2Flogger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devuri%2Flogger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devuri","download_url":"https://codeload.github.com/devuri/logger/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250344517,"owners_count":21415138,"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":[],"created_at":"2024-11-29T05:14:23.194Z","updated_at":"2026-01-24T17:32:51.398Z","avatar_url":"https://github.com/devuri.png","language":"PHP","readme":"# PSR Logger\n\nThis package provides a flexible PSR-3 compliant logging solution for your PHP application. It includes a logger with support for all PSR-3 log levels and optional logging to custom files or falling back to `error_log()` when no log file is provided.\n\n## Features\n\n- **PSR-3 Compliant**: Supports all PSR-3 log levels (`emergency`, `alert`, `critical`, `error`, `warning`, `notice`, `info`, `debug`).\n- **File Logging**: Logs to a specified file, automatically creating the file and necessary directories if they do not exist.\n- **Fallback to `error_log()`**: If no log file is specified, the package will fall back to PHP’s built-in `error_log()`.\n- **Easy Setup and Use**: A simple static interface (`Log`) to use in your application.\n\n## Installation\n\nTo install the package, you can use Composer:\n\n```bash\ncomposer require devuri/logger\n```\n\nMake sure to include Composer's autoloader in your project:\n\n```php\nrequire 'vendor/autoload.php';\n```\n\n## Usage\n\n### Initialization\n\nYou can initialize the logger by specifying a log file. If no file is provided, it will fall back to `error_log()`.\n\n```php\nuse Urisoft\\Log;\nuse Urisoft\\FileLogger;\n\n// Initialize the logger with a custom log file\n$logFile = __DIR__ . '/logs/app.log';\nLog::init(new FileLogger($logFile));\n```\n\n### Logging Messages\n\nYou can log messages at various levels using the following methods:\n\n```php\n// Log an informational message\nLog::info('Application started successfully.');\n\n// Log an error with context (PSR-3 interpolation)\nLog::error('Error occurred: {error}', ['error' =\u003e 'Database connection failed']);\n\n// Log a warning message\nLog::warning('Low disk space warning.');\n\n// Log a critical error\nLog::critical('Critical issue encountered in payment processing.');\n```\n\n### Log Levels\n\nThe package supports the following log levels:\n\n- `Log::emergency($message, $context = [])`\n- `Log::alert($message, $context = [])`\n- `Log::critical($message, $context = [])`\n- `Log::error($message, $context = [])`\n- `Log::warning($message, $context = [])`\n- `Log::notice($message, $context = [])`\n- `Log::info($message, $context = [])`\n- `Log::debug($message, $context = [])`\n\n### Creating the Log File Automatically\n\nIf the log file or its directories do not exist, the logger will create them automatically:\n\n```php\nuse Urisoft\\Log;\nuse Urisoft\\FileLogger;\n\n$logFile = __DIR__ . '/logs/application.log';\nLog::init(new FileLogger($logFile));  \n\nLog::info('Logging system initialized.');\n```\n\n## Configuration\n\n### Custom `error_log()`\n\nIf no log file is provided, the package will fall back to using PHP’s `error_log()` function. You can configure where `error_log()` writes by setting the `error_log` directive in your `php.ini` or using `ini_set()`:\n\n```php\n// Redirect error_log to a custom file\nini_set('error_log', __DIR__ . '/logs/error.log');\n\n// Initialize logger without a file to fallback to error_log\nLog::init(new FileLogger());\n```\n\n## License\n\nThis package is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).\n\n### Additional Notes:\n\n- **Error Handling**: If the logger cannot create the log file or write to the specified location, it will throw a `RuntimeException` with a relevant message.\n- **Log Rotation**: This package does not include log rotation functionality by default, so you may want to use external tools or another package to handle log rotation.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevuri%2Flogger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevuri%2Flogger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevuri%2Flogger/lists"}