-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from cesargb/v2
v2
- Loading branch information
Showing
23 changed files
with
245 additions
and
298 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Upgrading | ||
|
||
Because there are many breaking changes an upgrade is not that easy. There are many edge cases this guide does not cover. We accept PRs to improve this guide. | ||
|
||
## From [v1](https://github.com/cesargb/laravel-logs-rotate/tree/v1) to v2 | ||
|
||
- rename config params from `foreing_files` to `foreign_files`, if you have a config file with the old name, rename it to `config/rotate.php` | ||
- remove feat archive. | ||
- remove config params `archive_dir` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace Cesargb\LaravelLog\Commands; | ||
|
||
use Cesargb\LaravelLog\Helpers\Log as LogHelper; | ||
use Cesargb\LaravelLog\Rotate as LaravelLogRotate; | ||
use Illuminate\Console\Command; | ||
|
||
class RotateCommand extends Command | ||
{ | ||
protected $signature = 'rotate:logs'; | ||
|
||
protected $description = 'Rotate logs of Laravel'; | ||
|
||
public function handle() | ||
{ | ||
$this->rotateLaravelLogs(); | ||
|
||
$this->rotareForeingFiles(); | ||
} | ||
|
||
protected function rotateLaravelLogs() | ||
{ | ||
foreach (LogHelper::getLaravelLogFiles() as $file) { | ||
$this->line('Rotate file: '.$file); | ||
|
||
$this->rotateFile($file); | ||
} | ||
} | ||
|
||
protected function rotareForeingFiles() | ||
{ | ||
foreach (config('rotate.foreign_files', []) as $file) { | ||
$this->line('Rotate file: '.$file); | ||
|
||
$this->rotateFile($file); | ||
} | ||
} | ||
|
||
protected function rotateFile(string $filename) | ||
{ | ||
$rotation = new LaravelLogRotate(); | ||
|
||
$rotation->file($filename); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Cesargb\LaravelLog\Commands; | ||
|
||
use Cesargb\LaravelLog\Rotate; | ||
use Illuminate\Console\Command; | ||
|
||
class RotateFileCommand extends Command | ||
{ | ||
protected $signature = 'rotate:files | ||
{--f|file=* : Files to rotate} | ||
{--c|compress=true : Compress the file rotated} | ||
{--m|max-files=5 : Max files rotated} | ||
{--d|dir= : Dir where archive the file rotated}'; | ||
|
||
protected $description = 'Rotate files'; | ||
|
||
public function handle() | ||
{ | ||
foreach ($this->option('file') as $filename) { | ||
$this->line('Rotate file '.basename($filename).': '); | ||
|
||
$rotate = new Rotate(); | ||
|
||
$rotate->file($filename, [ | ||
'files' => config('rotate.log_max_files', 366), | ||
'compress' => config('rotate.log_compress_files', true), | ||
// 'then' => function () { | ||
// $this->line('<info>ok</>'); | ||
// }, | ||
// 'catch' => function ($error) { | ||
// $this->error('<comment>failed: '.$error->getMessage().'</>'); | ||
// }, | ||
]); | ||
} | ||
} | ||
} |
Oops, something went wrong.