Skip to content

Commit

Permalink
ICL: getLogPath method extracted.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-ivanov committed Jun 18, 2016
1 parent c03fb7a commit 5111a6f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/Loggable.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Illuminated\Console;

use Illuminate\Support\Str;
use Illuminated\Console\Log\Formatter;
use Monolog\Handler\RotatingFileHandler;
use Monolog\Logger;
Expand Down Expand Up @@ -45,14 +46,16 @@ protected function initializeLogging()

private function getLogHandlers()
{
$type = $this->type();
$entity = $this->argument('entity');
$path = storage_path("logs/cloud/{$type}/{$entity}/date.log");

$rotatingFileHandler = new RotatingFileHandler($path, 30);
$rotatingFileHandler = new RotatingFileHandler($this->getLogPath(), 30);
$rotatingFileHandler->setFilenameFormat('{date}', 'Y-m-d');
$rotatingFileHandler->setFormatter(new Formatter());

return [$rotatingFileHandler];
}

protected function getLogPath()
{
$name = Str::replaceFirst(':', '/', $this->getName());
return storage_path("logs/{$name}/date.log");
}
}

0 comments on commit 5111a6f

Please sign in to comment.