Skip to content

Commit

Permalink
Merge pull request #2 from CrazyProgg/feature/less-logs-for-testing
Browse files Browse the repository at this point in the history
Ignore if env is testing
  • Loading branch information
MsNatali authored Mar 10, 2023
2 parents 0387223 + 67d4738 commit b654d37
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/LaravelStdoutLogsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@

class LaravelStdoutLogsHelper
{
public static $ignoreEnvs = ['testing'];

public static function addStdoutStacks(array $config, array $mirrorDrivers = ['daily', 'single']): array
{
if (self::isIgnore()) {
return $config;
}

$newChannels = [];
foreach ($config['channels'] as $name => $channelSpec) {
$driver = $channelSpec['driver'] ?? null;
Expand All @@ -32,6 +38,10 @@ public static function addStdoutStacks(array $config, array $mirrorDrivers = ['d

public static function getNamesForStack(string $name): array
{
if (self::isIgnore()) {
return [$name];
}

return ["{$name}:stdout", "{$name}:original"];
}

Expand Down Expand Up @@ -67,4 +77,13 @@ public static function makeDailyChannel(string $path, int $ttlDays = 14, string
'days' => $ttlDays,
];
}

protected static function isIgnore(): bool
{
if (!function_exists('env')) {
return false;
}

return in_array(env('APP_ENV', 'production'), self::$ignoreEnvs);
}
}

0 comments on commit b654d37

Please sign in to comment.