{"id":18576120,"url":"https://github.com/thiagodp/logger","last_synced_at":"2025-05-16T00:34:44.263Z","repository":{"id":57040944,"uuid":"63015628","full_name":"thiagodp/logger","owner":"thiagodp","description":"A very simple logger for PHP. No magic configuration required. Just the basic features you need most.","archived":false,"fork":false,"pushed_at":"2018-02-12T23:59:54.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-17T15:16:03.063Z","etag":null,"topics":["log","logger","php","phputil"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thiagodp.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}},"created_at":"2016-07-10T19:44:54.000Z","updated_at":"2017-04-25T22:12:10.000Z","dependencies_parsed_at":"2022-08-24T01:10:48.731Z","dependency_job_id":null,"html_url":"https://github.com/thiagodp/logger","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thiagodp%2Flogger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thiagodp%2Flogger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thiagodp%2Flogger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thiagodp%2Flogger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thiagodp","download_url":"https://codeload.github.com/thiagodp/logger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254447882,"owners_count":22072755,"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","php","phputil"],"created_at":"2024-11-06T23:23:40.653Z","updated_at":"2025-05-16T00:34:44.227Z","avatar_url":"https://github.com/thiagodp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Logger\n\nA very simple logger for PHP. No magic configuration required. Just the basic features you need most.\n\nProvided interfaces and classes:\n\n* [phputil\\Logger](https://github.com/thiagodp/logger/blob/master/lib/Logger.php) interface\n* [phputil\\BaseLogger](https://github.com/thiagodp/logger/blob/master/lib/BaseLogger.php) abstract class\n* [phputil\\TextFileLogger](https://github.com/thiagodp/logger/blob/master/lib/TextFileLogger.php) class\n* [phputil\\FakeLogger](https://github.com/thiagodp/logger/blob/master/lib/FakeLogger.php) class (v1.1+)\n* [phputil\\EchoLogger](https://github.com/thiagodp/logger/blob/master/lib/EchoLogger.php) class (v1.3+)\n\nAvailable log methods:\n\n* `bool debug( string $message, Exception $e = null, array $context = array() );`\n* `bool info( string $message, Exception $e = null, array $context = array() );`\n* `bool warn( string $message, Exception $e = null, array $context = array() );`\n* `bool error( string $message, Exception $e = null, array $context = array() );`\n* `bool log( string $logType, string $message, Exception $e = null, array $context = array() );`\n\n### Installation\n\n```command\ncomposer require phputil/logger\n```\n\n### Example 1\n\n```php\n\u003c?php\nrequire_once 'vendor/autoload.php'; // composer\n\nuse phputil\\TextFileLogger;\n\n// It is recommended to set the DateTimeZone when using TextFileLogger.\n$logger = new TextFileLogger( 'log.txt', false, new \\DateTimeZone( 'America/Sao_Paulo' ) );\n\n$logger-\u003einfo( 'Something will happen' );\n$logger-\u003edebug( 'Something happened.' );\n$logger-\u003ewarn( 'Wait!' );\n$logger-\u003eerror( 'Ouch.' );\n\n$logger-\u003elog( Logger::DEBUG, \"That's awesome!\" );\n?\u003e\n```\n\n### Example 2\n\n```php\n\u003c?php\nrequire_once 'vendor/autoload.php'; // composer\n\nuse phputil\\Logger;\nuse phputil\\TextFileLogger;\nuse phputil\\FakeLogger;\n\n$inDebugMode = true;\n\n$logger = $inDebugMode\n\t? new TextFileLogger( 'log.txt', false, new \\DateTimeZone( 'America/Sao_Paulo' ) )\n\t: new FakeLogger();\n\n$logger-\u003einfo( 'Something will happen' );\ntry {\n\tthrow new \\Exception( 'Hummm... something bad happened.' );\n} catch ( \\Exception $e ) {\n\t// Logs message and trace\n\t$logger-\u003eerror( 'Ouch, I did not expect that!', $e );\n}\n\n$logger-\u003elog( Logger::DEBUG, \"That's awesome!\" );\n?\u003e\n```\n\n### Example 3\n\n```php\n\u003c?php\nrequire_once 'vendor/autoload.php'; // composer\n\nuse phputil\\EchoLogger;\n\n$logger = new EchoLogger();\n$logger-\u003einfo( 'It can log to the console too!' );\n?\u003e\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthiagodp%2Flogger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthiagodp%2Flogger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthiagodp%2Flogger/lists"}