-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogger.php
More file actions
77 lines (67 loc) · 1.77 KB
/
Logger.php
File metadata and controls
77 lines (67 loc) · 1.77 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
declare(strict_types = 1);
namespace Innmind\OperatingSystem\Remote;
use Innmind\OperatingSystem\Remote;
use Innmind\Server\Control;
use Innmind\IO\Sockets\Internet\Transport;
use Innmind\Url\{
Url,
Authority,
};
use Innmind\HttpTransport;
use Innmind\Immutable\Attempt;
use Formal\AccessLayer\Connection;
use Psr\Log\LoggerInterface;
final class Logger implements Remote
{
private Remote $remote;
private LoggerInterface $logger;
private function __construct(Remote $remote, LoggerInterface $logger)
{
$this->remote = $remote;
$this->logger = $logger;
}
public static function psr(Remote $remote, LoggerInterface $logger): self
{
return new self($remote, $logger);
}
#[\Override]
public function ssh(Url $server): Control\Server
{
return Control\Servers\Logger::psr(
$this->remote->ssh($server),
$this->logger,
);
}
#[\Override]
public function socket(Transport $transport, Authority $authority): Attempt
{
$this->logger->debug(
'Opening remote socket at {address}',
[
'address' => \sprintf(
'%s://%s',
$transport->toString(),
$authority->toString(),
),
],
);
return $this->remote->socket($transport, $authority);
}
#[\Override]
public function http(): HttpTransport\Transport
{
return HttpTransport\Logger::psr(
$this->remote->http(),
$this->logger,
);
}
#[\Override]
public function sql(Url $server): Connection
{
return Connection\Logger::psr(
$this->remote->sql($server),
$this->logger,
);
}
}