-
-
Notifications
You must be signed in to change notification settings - Fork 466
Expand file tree
/
Copy pathLogs.php
More file actions
107 lines (92 loc) · 3.65 KB
/
Logs.php
File metadata and controls
107 lines (92 loc) · 3.65 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
declare(strict_types=1);
namespace Sentry\Logs;
use Sentry\EventId;
use Sentry\SentrySdk;
class Logs
{
/**
* @var self|null
*/
private static $instance;
private function __construct()
{
}
public static function getInstance(): self
{
if (self::$instance === null) {
self::$instance = new self();
}
return self::$instance;
}
/**
* @param string $message see sprintf for a description of format
* @param array<int, string|int|float> $values see sprintf for a description of values
* @param array<string, mixed> $attributes additional attributes to add to the log
*/
public function trace(string $message, array $values = [], array $attributes = []): void
{
$this->aggregator()->add(LogLevel::trace(), $message, $values, $attributes);
}
/**
* @param string $message see sprintf for a description of format
* @param array<int, string|int|float> $values see sprintf for a description of values
* @param array<string, mixed> $attributes additional attributes to add to the log
*/
public function debug(string $message, array $values = [], array $attributes = []): void
{
$this->aggregator()->add(LogLevel::debug(), $message, $values, $attributes);
}
/**
* @param string $message see sprintf for a description of format
* @param array<int, string|int|float> $values see sprintf for a description of values
* @param array<string, mixed> $attributes additional attributes to add to the log
*/
public function info(string $message, array $values = [], array $attributes = []): void
{
$this->aggregator()->add(LogLevel::info(), $message, $values, $attributes);
}
/**
* @param string $message see sprintf for a description of format
* @param array<int, string|int|float> $values see sprintf for a description of values
* @param array<string, mixed> $attributes additional attributes to add to the log
*/
public function warn(string $message, array $values = [], array $attributes = []): void
{
$this->aggregator()->add(LogLevel::warn(), $message, $values, $attributes);
}
/**
* @param string $message see sprintf for a description of format
* @param array<int, string|int|float> $values see sprintf for a description of values
* @param array<string, mixed> $attributes additional attributes to add to the log
*/
public function error(string $message, array $values = [], array $attributes = []): void
{
$this->aggregator()->add(LogLevel::error(), $message, $values, $attributes);
}
/**
* @param string $message see sprintf for a description of format
* @param array<int, string|int|float> $values see sprintf for a description of values
* @param array<string, mixed> $attributes additional attributes to add to the log
*/
public function fatal(string $message, array $values = [], array $attributes = []): void
{
$this->aggregator()->add(LogLevel::fatal(), $message, $values, $attributes);
}
/**
* Flush the captured logs and send them to Sentry.
*/
public function flush(): ?EventId
{
return $this->aggregator()->flush();
}
/**
* Get the logs aggregator.
*
* @internal
*/
public function aggregator(): LogsAggregator
{
return SentrySdk::getCurrentRuntimeContext()->getLogsAggregator();
}
}