{"id":21771127,"url":"https://github.com/initphp/logger","last_synced_at":"2026-03-09T08:02:04.403Z","repository":{"id":56991540,"uuid":"470087007","full_name":"InitPHP/Logger","owner":"InitPHP","description":"Library developed for logging to file or database in PSR-3 standards.","archived":false,"fork":false,"pushed_at":"2023-12-15T17:30:50.000Z","size":6,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-06T17:59:09.927Z","etag":null,"topics":["logger","php","php-logger","php-logging","php-logging-library","psr-3"],"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/InitPHP.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,"zenodo":null}},"created_at":"2022-03-15T09:25:25.000Z","updated_at":"2022-05-26T19:36:34.000Z","dependencies_parsed_at":"2025-04-13T16:51:43.648Z","dependency_job_id":null,"html_url":"https://github.com/InitPHP/Logger","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/InitPHP/Logger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InitPHP%2FLogger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InitPHP%2FLogger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InitPHP%2FLogger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InitPHP%2FLogger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/InitPHP","download_url":"https://codeload.github.com/InitPHP/Logger/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InitPHP%2FLogger/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30287446,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T02:57:19.223Z","status":"ssl_error","status_checked_at":"2026-03-09T02:56:26.373Z","response_time":61,"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":["logger","php","php-logger","php-logging","php-logging-library","psr-3"],"created_at":"2024-11-26T14:15:09.834Z","updated_at":"2026-03-09T08:02:04.395Z","avatar_url":"https://github.com/InitPHP.png","language":"PHP","readme":"# InitPHP Logger\n\nLogger class in accordance with PSR-3 standards\n\n[![Latest Stable Version](http://poser.pugx.org/initphp/logger/v)](https://packagist.org/packages/initphp/logger) [![Total Downloads](http://poser.pugx.org/initphp/logger/downloads)](https://packagist.org/packages/initphp/logger) [![Latest Unstable Version](http://poser.pugx.org/initphp/logger/v/unstable)](https://packagist.org/packages/initphp/logger) [![License](http://poser.pugx.org/initphp/logger/license)](https://packagist.org/packages/initphp/logger) [![PHP Version Require](http://poser.pugx.org/initphp/logger/require/php)](https://packagist.org/packages/initphp/logger)\n\n## Features\n\n- Keeping logs to the database with PDO.\n- Printing log records to a file.\n- Logging feature with multiple drivers.\n\n## Requirements\n\n- PHP 5.6 or higher\n- [PSR-3 Interface Package](https://www.php-fig.org/psr/psr-3/)\n- PDO Extension (Only `PDOLogger`)\n\n## Installation\n\n```\ncomposer require initphp/logger\n```\n\n## Using\n\n### FileLogger\n\n```php \nrequire_once \"vendor/autoload.php\";\nuse \\InitPHP\\Logger\\Logger;\nuse \\InitPHP\\Logger\\FileLogger;\n\n$logFile = __DIR__ . '/logfile.log';\n\n$logger = new Logger(new FileLogger(['path' =\u003e $logFile]));\n```\n\n### PdoLogger\n\n```php \nrequire_once \"vendor/autoload.php\";\nuse \\InitPHP\\Logger\\Logger;\nuse \\InitPHP\\Logger\\PDOLogger;\n\n$table = 'logs';\n$pdo = new \\PDO('mysql:dbname=project;host=localhost', 'root', '');\n\n$logger = new Logger(new PDOLogger(['pdo' =\u003e $pdo, 'table' =\u003e $table]));\n\n$logger-\u003eerror('User {user} caused an error.', array('user' =\u003e 'muhametsafak'));\n// INSERT INTO logs (level, message, date) VALUES ('ERROR', 'User muhametsafak caused an error.', '2022-03-11 13:05:45')\n```\n\nYou can use the following SQL statement to create a sample MySQL table.\n\n```sql \nCREATE TABLE `logs` (\n    `level` ENUM('EMERGENCY','ALERT','CRITICAL','ERROR','WARNING','NOTICE','INFO','DEBUG') NOT NULL,\n    `message` TEXT NOT NULL,\n    `date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP\n) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;\n```\n\n### Multi Logger\n\n```php \nrequire_once \"vendor/autoload.php\";\nuse \\InitPHP\\Logger\\Logger;\nuse \\InitPHP\\Logger\\PDOLogger;\nuse \\InitPHP\\Logger\\FileLogger;\n\n$logFile = __DIR__ . '/logfile.log';\n\n$table = 'logs';\n$pdo = new \\PDO('mysql:dbname=project;host=localhost', 'root', '');\n\n$logger = new Logger(new FileLogger(['path' =\u003e $logFile]), new PDOLogger(['pdo' =\u003e $pdo, 'table' =\u003e $table]));\n```\n\n## Methods\n\n```php\npublic function emergency(string $msg, array $context = array()): void;\n\npublic function alert(string $msg, array $context = array()): void;\n\npublic function critical(string $msg, array $context = array()): void;\n\npublic function error(string $msg, array $context = array()): void;\n\npublic function warning(string $msg, array $context = array()): void;\n\npublic function notice(string $msg, array $context = array()): void;\n\npublic function info(string $msg, array $context = array()): void;\n\npublic function debug(string $msg, array $context = array()): void;\n\npublic function log(string $level, string $msg, array $context = array()): void;\n```\n\nAll of the above methods are used the same way, except for the `log()` method. You can use the `log()` method for your own custom error levels.\n\n**Example 1 :**\n\n```php\n$logger-\u003eemergency(\"Something went wrong\");\n```\n\nIt prints an output like this to the log file.\n\n```\n2021-09-29T13:34:47+02:00 [EMERGENCY] Something went wrong\n```\n\n**Example 2:**\n\n```php\n$logger-\u003eerror(\"User {username} caused an error.\", [\"username\" =\u003e \"john\"]);\n```\n\nIt prints an output like this to the log file.\n\n```\n2021-09-29T13:34:47+02:00 [ERROR] User john caused an error.\n```\n\nThat is all.\n\n***\n\n## Getting Help\n\nIf you have questions, concerns, bug reports, etc, please file an issue in this repository's Issue Tracker.\n\n## Credits\n\n- [Muhammet ŞAFAK](https://www.muhammetsafak.com.tr)\n\n## License\n\nCopyright \u0026copy; 2022 [MIT License](./LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finitphp%2Flogger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finitphp%2Flogger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finitphp%2Flogger/lists"}