blob: f65f1e8566b30c09b80b78458703f80c7dcbcd66 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
<?php
declare(strict_types=1);
namespace OpenTelemetry\API\Behavior\Internal\LogWriter;
class StreamLogWriter implements LogWriterInterface
{
private $stream;
public function __construct(string $destination)
{
$stream = fopen($destination, 'a');
if ($stream) {
$this->stream = $stream;
} else {
throw new \RuntimeException(sprintf('Unable to open %s for writing', $destination));
}
}
public function write($level, string $message, array $context): void
{
fwrite($this->stream, Formatter::format($level, $message, $context));
}
}
|