Skip to content

Commit

Permalink
Merge pull request #4 from reallyli/add-log-config
Browse files Browse the repository at this point in the history
添加 log 配置
  • Loading branch information
reallyli committed Apr 2, 2019
2 parents 4ec9290 + 57ec5e5 commit 9796711
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 5 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
"require-dev": {
"mockery/mockery": "^1.0",
"codedungeon/phpunit-result-printer": "^0.19.13",
"phpunit/phpunit": "^7.0",
"orchestra/testbench": "~3.5.0|~3.6.0"
"phpunit/phpunit": "^7.0"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 2 additions & 0 deletions deploy.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ options:
notify_channel_url: null
repository: null
shared_dirs: null
log_file_name: laravel.log
log_lines: 200
hosts: []
localhost: []
include: []
Expand Down
11 changes: 9 additions & 2 deletions src/task/logs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@

namespace Deployer;

set('log_lines', 200);
set('log_command', 'cat storage/logs/laravel.log | grep -Ev "^#[[:digit:]]|^\[stacktrace\]$|^\"\}$" | tail -n {{log_lines}}');
set('log_lines', function () {
return get('log_line', 200);
});

set('log_file_name', function () {
return get('log_file_name', 'laravel.log');
});

set('log_command', 'cat storage/logs/{{log_file_name}} | grep -Ev "^#[[:digit:]]|^\[stacktrace\]$|^\"\}$" | tail -n {{log_lines}}');

desc('Read logs from a given host');
task('logs', function () {
Expand Down
2 changes: 1 addition & 1 deletion src/task/notify.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
function sendGroupNotify(string $content)
{
if (! get('notify_channel_url')) {
throw new \Exception('[Laravel-Deployer]Notification is on but channel url is not set!');
throw new \InvalidArgumentException('[Laravel-Deployer]Notification is on but channel url is not set!');
}

$data = json_encode(['text' => $content]);
Expand Down
2 changes: 2 additions & 0 deletions tests/.build/deploy.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
set('notify_channel_url', null);
set('repository', null);
set('shared_dirs', null);
set('log_file_name', 'laravel.log');
set('log_lines', 200);

/*
* Hosts and localhost
Expand Down
2 changes: 2 additions & 0 deletions tests/Features/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ options:
notify_channel_url: null
repository: null
shared_dirs: null
log_file_name: laravel.log
log_lines: 200
hosts: { }
localhost: { }
include: { }
Expand Down

0 comments on commit 9796711

Please sign in to comment.