I am again having more problems with Laravel, as I have problems with understanding.
Again, I'm trying to create a package for my own logging. After doing some additional reading and looking at the main code and trying other approaches, I came to the conclusion that all I need to do is expand the main functions of laravel logging so that it is logged in a different way using a custom formatter.
I created my package. Here is my class of service provider:
use Illuminate\Log\LogServiceProvider;
class VmlogServiceProvider extends LogServiceProvider {
public function boot()
{
App::bind('log', function()
{
return new Vm\Vmlog\Vmlog;
});
parent::boot();
}
}
?>
Here is the VmLog class
<?php namespace Vm\Vmlog;
use App;
use Illuminate\Support\ServiceProvider;
use Log;
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\RotatingFileHandler;
class Vmlog extends \Illuminate\Log\Writer {
protected $path;
protected $formatter;
protected $stream;
protected $rotatingStream;
public function __construct() {
$output = APP_HOST."|%datetime%|%level%|%level_name%|".__METHOD__."|%message%|%context%".PHP_EOL;
$this->path = VM_LOGPATH.APP_VLCODE."/".APP_VLCODE."_".APP_INSTANCE.".log";
$this->formatter = new LineFormatter($output, $dateFormat);
parent::__construct();
}
public function useFiles($path, $level = 'debug')
{
$level = $this->parseLevel($level);
$this->stream = new StreamHandler($this->path, $level);
$this->stream->setFormatter($this->formatter);
$this->monolog->pushHandler($this->stream);
}
public function useDailyFiles($path, $days = 0, $level = 'debug')
{
$level = $this->parseLevel($level);
$this->rotatingStream = new RotatingFileHandler($this->path, $days, $level);
$this->rotatingStream->setFormatter($this->formatter);
$this->monolog->pushHandler($this->rotatingStream);
}
}
?>
I commented on LogServiceProvider in app.php and added it to my VmlogServiceProvider in this place.
However, when I try to run things, I get the following error.
Call the undefined method Illuminate \ Support \ Facades \ Log :: useDailyFiles ()
, . LogServiceProvider, , ( ). ?