Skip to content

Commit a733c3f

Browse files
committed
Add syslog output
1 parent c5ad84e commit a733c3f

File tree

5 files changed

+35
-3
lines changed

5 files changed

+35
-3
lines changed

config/soar.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
// Guanguans\LaravelSoar\Outputs\ConsoleOutput::class,
4040
// Guanguans\LaravelSoar\Outputs\DumpOutput::class => ['exit' => false],
4141
// Guanguans\LaravelSoar\Outputs\RayOutput::class => ['label' => 'Soar Scores'],
42+
// Guanguans\LaravelSoar\Outputs\SyslogOutput::class,
4243
Guanguans\LaravelSoar\Outputs\JsonOutput::class => ['key' => 'soar_scores'],
4344
Guanguans\LaravelSoar\Outputs\LogOutput::class => ['channel' => 'daily'],
4445
Guanguans\LaravelSoar\Outputs\DebugBarOutput::class,

psalm-baseline.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,6 @@
105105
</PossiblyUnusedMethod>
106106
</file>
107107
<file src="src/Outputs/RayOutput.php">
108-
<UnusedClass>
109-
<code>RayOutput</code>
110-
</UnusedClass>
111108
<InvalidArgument>
112109
<code>$scores</code>
113110
</InvalidArgument>

psalm.xml.dist

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
<file name="src/Macros/QueryBuilderMacro.php"/>
3535
</errorLevel>
3636
</InvalidArgument>
37+
<UnusedClass>
38+
<errorLevel type="suppress">
39+
<directory name="src/Outputs"/>
40+
</errorLevel>
41+
</UnusedClass>
3742
</issueHandlers>
3843
<plugins>
3944
<!--<pluginClass class="Psalm\LaravelPlugin\Plugin"/>-->

src/Outputs/SyslogOutput.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of the guanguans/laravel-soar.
7+
*
8+
* (c) guanguans <ityaozm@gmail.com>
9+
*
10+
* This source file is subject to the MIT license that is bundled.
11+
*/
12+
13+
namespace Guanguans\LaravelSoar\Outputs;
14+
15+
use Illuminate\Support\Collection;
16+
17+
class SyslogOutput extends Output
18+
{
19+
/**
20+
* {@inheritDoc}
21+
*
22+
* @throws \JsonException
23+
*/
24+
public function output(Collection $scores, $dispatcher): void
25+
{
26+
$scores->each(fn (array $score) => syslog(LOG_WARNING, $score['Summary'].PHP_EOL.to_pretty_json($score)));
27+
}
28+
}

tests/TestCase.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ protected function defineEnvironment($app): void
7070
ConsoleOutput::class,
7171
// \Guanguans\LaravelSoar\Outputs\DebugBarOutput::class,
7272
// \Guanguans\LaravelSoar\Outputs\DumpOutput::class => ['exit' => false],
73+
\Guanguans\LaravelSoar\Outputs\SyslogOutput::class,
7374
JsonOutput::class,
7475
LogOutput::class => ['channel' => 'daily'],
7576
NullOutput::class,

0 commit comments

Comments
 (0)