1. Go to this page and download the library: Download salibhdr/php-dump-logger library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$logger->silent(); //result will be true for success and false for failed attempt to log
use SaliBhdr\DumpLog\Factory\Logger;
$logger = Logger::make(); // the pretty logger is the default logger
// or
$logger = Logger::make('pretty');
// or
$logger = Logger::pretty();
use SaliBhdr\DumpLog\Factory\Logger;
$logger = Logger::make('html');
// or
$logger = Logger::html();
use SaliBhdr\DumpLog\Loggers\RawLogger;
use Symfony\Component\VarDumper\Dumper\CliDumper;
$dumper = new CliDumper();
$logger = new RawLogger();
$extension = 'txt';
$logger->path('__path_to_dir__')
->dumper($dumper, $extension)
->log($data)
namespace App;
use SaliBhdr\DumpLog\Contracts\DumperStrategyInterface;
use Symfony\Component\VarDumper\Dumper\AbstractDumper;
use Symfony\Component\VarDumper\Dumper\CliDumper;
class CustomDumperStrategy implements DumperStrategyInterface
{
public function getDumper() : AbstractDumper
{
# Here we want to render the log content with CliDumper
return new CliDumper();
}
public function getExtension() : string
{
# Here we want to save it as text file
return 'txt';
}
public function getTitle(): string
{
# title will be shown on top of each log (usually it's better to add the date and time)
return "\n" . date('H:i:s') . "\n"
}
}
use App\CustomDumperStrategy;
use SaliBhdr\DumpLog\Contracts\DumpLoggerInterface;
class CustomTextLogger implements DumpLoggerInterface
{
use LogsThroughRawLogger;
protected $logger;
public function __construct()
{
$this->logger = (new RawLogger())
->dumper(new CustomDumperStrategy())
->path('__path-to-dir__');
}
}
use SaliBhdr\DumpLog\Factory\Logger;
Logger::make()
->path('__path-to-dir__')
->dir('__custom-dir-name__')
->daily(true)
->silent(true)
->permission(0777)
->info($data);
sh
composer
text
---| 2023-01-18 14:01:54 |-------------------------------------------------------------------------------------------
array:5 [
"class" => "Exception"
"massage" => "exception message"
"code" => 500
"file" => "__path_to_file__"
"line" => 356
"trace" => array:12 [...] // appears only if $withTrace is true
]
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.