{"id":19324984,"url":"https://github.com/spatie/laravel-log-dumper","last_synced_at":"2025-05-15T22:03:38.967Z","repository":{"id":46026207,"uuid":"252556022","full_name":"spatie/laravel-log-dumper","owner":"spatie","description":"A function to dump anything to the log","archived":false,"fork":false,"pushed_at":"2025-02-17T16:18:17.000Z","size":88,"stargazers_count":120,"open_issues_count":0,"forks_count":10,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-05-15T22:03:02.104Z","etag":null,"topics":["development","dump","laravel","log"],"latest_commit_sha":null,"homepage":"https://spatie.be/open-source","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/spatie.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","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},"funding":{"github":"spatie","custom":"https://spatie.be/open-source/support-us"}},"created_at":"2020-04-02T20:11:48.000Z","updated_at":"2025-04-04T04:40:54.000Z","dependencies_parsed_at":"2024-02-28T11:30:57.416Z","dependency_job_id":"680dfbee-0e25-4880-b994-7ab666a8293f","html_url":"https://github.com/spatie/laravel-log-dumper","commit_stats":{"total_commits":71,"total_committers":11,"mean_commits":6.454545454545454,"dds":0.3943661971830986,"last_synced_commit":"3808be74da83793c96bafb425bbcdc1654f67743"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-log-dumper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-log-dumper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-log-dumper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-log-dumper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spatie","download_url":"https://codeload.github.com/spatie/laravel-log-dumper/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254430325,"owners_count":22069907,"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":["development","dump","laravel","log"],"created_at":"2024-11-10T02:08:20.718Z","updated_at":"2025-05-15T22:03:38.911Z","avatar_url":"https://github.com/spatie.png","language":"PHP","funding_links":["https://github.com/sponsors/spatie","https://spatie.be/open-source/support-us"],"categories":[],"sub_categories":[],"readme":"# A function to dump anything to the log\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/laravel-log-dumper.svg?style=flat-square)](https://packagist.org/packages/spatie/laravel-log-dumper)\n[![run-tests](https://github.com/spatie/laravel-log-dumper/actions/workflows/run-tests.yml/badge.svg)](https://github.com/spatie/laravel-log-dumper/actions/workflows/run-tests.yml)\n[![Total Downloads](https://img.shields.io/packagist/dt/spatie/laravel-log-dumper.svg?style=flat-square)](https://packagist.org/packages/spatie/laravel-log-dumper)\n\nThis package contains a function `ld`. Any argument you pass to it will be dumped to the log. You can pass any kind of value to it.\n\n```php\nld('a string', ['an array'], new Class());\n```\n\nUnder the hood, Symfony's `VarDumper` is used to create string representations.\n\n## Support us\n\n[\u003cimg src=\"https://github-ads.s3.eu-central-1.amazonaws.com/laravel-log-dumper.jpg?t=1\" width=\"419px\" /\u003e](https://spatie.be/github-ad-click/laravel-log-dumper)\n\nWe invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).\n\nWe highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require spatie/laravel-log-dumper\n```\n\n## Usage\n\nYou can pass any variable you want to `ld`.\n\n```php\nld('a string', ['an array'], new Class());\n```\n\nAll arguments will be converted to strings and will be written to the application log using the `info` level.\n\n## Using other log levels\n\nIf you want to use another log level, you can just call the method you want on `ld`. You can pass these methods any type of argument and any number of arguments. They will all be logged.\n\n```php\n// logs using the `error` level\nld()-\u003eerror('a string', ['an array'], new Class())\n```\n\nOf course, you can mix and chain different levels.\n\n```php\nld()\n   -\u003edebug('Debug info', ['an array'])\n   -\u003eerror('Error info', new Class);\n```\n\n## Enabling and disabling logging\n\nYou can disable logging by calling `disable`.\n\n```php\nld('foo'); // will be logged\n\nld()-\u003edisable();\n\nld('bar'); // will not be logged\n\nld()-\u003eenable();\n\nld('baz'); // will be logged\n```\n\nYou can pass a boolean to `enable`. This can be handy when you want to log only one iteration of a loop.\n\n```php\nforeach (range(1, 3) as $i) {\n   // only things in the third iteration will be logged\n   ld()-\u003eenable($i === 3);\n\n   ld('we are in the third iteration');\n}\n```\n\n## Logging queries\n\nYou can log all queries with `logQueries`.\n\n````php\nld()-\u003elogQueries(); // all queries after this call will be logged\n````\n\nIf you wish to stop logging queries, call `stopLoggingQueries`.\n\n````php\nld()-\u003estopLoggingQueries(); // all queries after this call will not be logged anymore\n````\n\nAlternatively to manually starting and stopping listening for queries, you can also pass a closure to `logQueries`. Only the queries executed inside the closure will be logged.\n\n````php\nld()-\u003elogQueries(function() {\n    $this-\u003emailAllUsers(); // all queries executed in this closure will be logged\n});\n\nUser::get(); // this query will not be logged\n````\n\n## Testing\n\n``` bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.\n\n## Security\n\nIf you've found a bug regarding security please mail [security@spatie.be](mailto:security@spatie.be) instead of using the issue tracker.\n\n## Credits\n\n- [Freek Van der Herten](https://github.com/freekmurze)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Flaravel-log-dumper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspatie%2Flaravel-log-dumper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Flaravel-log-dumper/lists"}