Skip to content

Commit

Permalink
Merge pull request #2 from outl1ne/optional-logging
Browse files Browse the repository at this point in the history
Add option to disable info logging - default true, add gitignore
  • Loading branch information
allantatter authored Jan 3, 2023
2 parents 273f930 + 7ed2ca5 commit ba16d19
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/.idea
/vendor
/node_modules
composer.phar
composer.lock
phpunit.xml
.phpunit.result.cache
.DS_Store
.env
1 change: 1 addition & 0 deletions config/console-over-http.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
return [
'token' => env('CONSOLE_OVER_HTTP_TOKEN', null),
'insecure' => env('CONSOLE_OVER_HTTP_INSECURE', false),
'debug_logs' => env('CONSOLE_OVER_HTTP_DEBUG_LOGS', true),
'process' => [
'timeout' => 3600,
],
Expand Down
6 changes: 4 additions & 2 deletions src/ConsoleOverHttpController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Http\Request;
use Symfony\Component\Process\Process;
use Illuminate\Support\Facades\Log;

class ConsoleOverHttpController extends BaseController
{
Expand All @@ -20,13 +21,14 @@ protected function console(Request $request)
$process->start();

echo '<html><body style="background:#000;font-family:monospace;">';
$debugLogsEnabled = config('console-over-http.debug_logs');

foreach ($process as $type => $data) {
if ($process::OUT === $type) {
\Log::info($data);
if ($debugLogsEnabled) Log::info($data);
echo "\n<span style='color:#ccc'>" . $data . "</span><br />";
} else {
\Log::error($data);
Log::error($data);
echo "\n<span style='color:red'>" . $data . "</span><br />";
}
}
Expand Down

0 comments on commit ba16d19

Please sign in to comment.