You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PHP dump logger uses [Symfony's var-dumper][link-symfony-var-dumper] to create a simple, easy to use, eye-friendly, and pretty log files for any PHP application.
43
-
If you are a fan of using `dd()` and `dump()`, this package is for you.
41
+
If you are a big fan of using `dd()` and `dump()`, this package is for you.
Have you ever tried to log something with Symfony's monologor laravel's logger facade and tried to find the logged data inside a maze of text?
47
+
Have you ever tried to log something with monolog, Symfony, or Laravel logger and tried to find the logged data inside a maze of text?
50
48
Especially when you don't have time and don't want to go through installing and configuring Xdebug or there is a bug in production code,
51
49
and you just want to see the API responses without messing with the code execution.
52
-
The first solution that comes to mind is to use a logger to log the data instead of using `dd()`, `dump()`, or `var_dump()` functions.
53
-
But as I said, loggers aren't producing readable files. You have to provide them with a string, and they are incapable of directly logging a complex class.
54
-
How nice would it be to have a functionality like `dd()` without interruption in the code?
50
+
51
+
The problem with `dd()`, `dump()`, or `var_dump()` functions is that they print the data, which is something
52
+
that sometimes you don't want, especially when the code execution should not be interrupted.
53
+
54
+
The first solution that comes to mind is to use a logger to log the data instead of using those print functions.
55
+
But as I said, loggers aren't producing readable files, and sometimes you have to only provide them with a string, and they are incapable
56
+
of directly logging a complex class. How nice would it be to have a functionality like `dd()` without interruption in the code?
55
57
56
58
Here **php-dump-logger** comes to the rescue.
57
59
58
-
**php-dump-logger** uses [Symfony's var-dumper][link-symfony-var-dumper] to generate the log file content and then saves the output to a file.
60
+
**php-dump-logger** uses [Symfony's var-dumper][link-symfony-var-dumper] to generate the log content
61
+
and then saves the output into a file. Which is by the way really pleasant in the eye.
59
62
You can either log the data in a nice `html` or `log` format or even provide your own dumper.
60
63
61
64
**Features**
@@ -64,7 +67,7 @@ You can either log the data in a nice `html` or `log` format or even provide you
64
67
* Readable log in `log` format
65
68
* Ability to log classes, arrays, objects, and basically any variable you like. There is no limit.
If you want to log the exception in a much more readable way You should use the `exception()` method.
166
-
It is good for creating logs for exceptions like this:
167
-
If You want to see the trace of the exception you can set the second argument named `$withTrace` to true:
169
+
This method is good for creating logs for exceptions. If You want to see the trace of the exception you can set
170
+
the second argument named `$withTrace` to true:
168
171
169
172
```php
170
173
try {
@@ -212,8 +215,8 @@ This will create a file named `custom-level.log`.
212
215
### Path <spanid="path"></span>
213
216
214
217
By default, the path to log directory is set to be `$_SERVER['DOCUMENT_ROOT']` but if you call this logger
215
-
from a console command the document rule will be null and the logger could not find a directory to save the file, and it will throw
216
-
InvalidArgument Exception. So make sure to prove the directory path like so:
218
+
from a console command the document root will be null and the logger could not find a directory to save the file, and it will throw
219
+
`InvalidArgumentException`. So make sure to provide the directory path like so:
217
220
218
221
```php
219
222
@@ -250,7 +253,7 @@ Sometimes you want to put your log files in a directory with restricted permissi
250
253
In order to do that you can change the log file's directory permission with the `permission()` method.
251
254
remember that This directory permission is only applied in the directory's first creation.
252
255
So you can't change the directory's permission after the creation.
253
-
Remember to provide the apache group with the right permissions to create and execute the file in the directory.
256
+
Remember to provide a group with the right permissions to create and execute the file in the directory.
254
257
You don't want to create a directory that even PHP could not write into it.
255
258
By default, the directory and the files inside it will have 0775 permission.
256
259
@@ -289,7 +292,7 @@ info-2023-02-01.log
289
292
290
293
Calling `silent()` method allows you to log data without throwing an error.
291
294
292
-
Remember that in some cases the logger will throw an error like when the $path is empty, or when it couldn't write into the target file for permission reasons.
295
+
Remember, in some cases the logger will throw an error when the $path is empty, or when it couldn't write into the target file for permission reasons.
293
296
294
297
So if you want to avoid that, and you don't want to interrupt the code execution, you can call `silent()` method.
295
298
In the background this method will force the logger to execute the code in try-catch block and return a boolean instead of the exception.
@@ -361,7 +364,7 @@ $logger = Logger::html();
361
364
362
365
Raw Logger is base logger class that other loggers are using it. The only difference between Raw Logger and the others is that there
363
366
is no dumper or path specified in this logger, and you have to provide a dumper and the file extension with `dumper()` and the path with `path()` method.
364
-
Otherwise, it will throw `SaliBhdr\DumpLog\ExceptionsInvalidArgumentException`
367
+
Otherwise, it will throw `SaliBhdr\DumpLog\Exceptions\InvalidArgumentException`
365
368
366
369
Remember that the dumper should be the instance of `Symfony\Component\VarDumper\Dumper\AbstractDumper`.
367
370
Feel free to create your own dumper and use the Raw logger.
You can create your own dump logger by implementing the `SaliBhdr\DumpLog\Contracts\DumpLoggerInterface` or `SaliBhdr\DumpLog\Contracts\ChangeableDumperLoggerInterface`.
390
-
You can also use the RawLogger in your own logger by first instantiating the RawLogger in your Logger and then use the `SaliBhdr\DumpLog\Traits\LogsThroughRawLogger` trait.
392
+
You can create your own dump logger by implementing one of these interfaces:
393
+
-`SaliBhdr\DumpLog\Contracts\DumpLoggerInterface` : Without the ability to change the dumper
394
+
-`SaliBhdr\DumpLog\Contracts\DumpLoggerAwareInterface` : You have to add `dumper()` setter
391
395
392
-
example:
396
+
You can also use the RawLogger in your own logger by first instantiating
0 commit comments