@@ -15,53 +15,19 @@ class MonologTap
15
15
/**
16
16
* Customize the given logger instance.
17
17
*/
18
- public function __invoke (Logger $ logger ): void
18
+ public function __invoke (Logger & $ logger ): void
19
19
{
20
20
$ this ->setStechFormatter ($ logger );
21
-
22
- $ this ->setDefaultContext ($ logger );
23
21
}
24
22
25
23
/**
26
24
* Sets up the key=value, pair format that we like best
27
25
*/
28
- public function setStechFormatter (Logger $ logger ): void
26
+ public function setStechFormatter (Logger & $ logger ): void
29
27
{
30
28
$ formatter = new MonologFormatter ;
31
29
foreach ($ logger ->getHandlers () as $ handler ) {
32
30
$ handler ->setFormatter ($ formatter );
33
31
}
34
32
}
35
-
36
- /**
37
- * Sets up a series of standardized contexts for us.
38
- */
39
- public function setDefaultContext (Logger $ logger ): void
40
- {
41
- $ logger ->pushProcessor (function ($ record ) {
42
- if (! in_array ($ record ['channel ' ], ['local ' , 'staging ' , 'production ' , 'lumen ' ])) {
43
- $ record ['context ' ]['channel ' ] = $ record ['channel ' ];
44
- }
45
- // Add some core parameters
46
- if (array_key_exists ('HTTP_HOST ' , $ _SERVER )) {
47
- $ record ['context ' ]['httpHost ' ] = $ _SERVER ['HTTP_HOST ' ];
48
- } else {
49
- $ record ['context ' ]['httpHost ' ] = 'CLI ' ;
50
- }
51
- if (array_key_exists ('REMOTE_ADDR ' , $ _SERVER )) {
52
- $ record ['context ' ]['IP ' ] = $ _SERVER ['REMOTE_ADDR ' ];
53
- }
54
- if (array_key_exists ('HTTP_X_FORWARDED_FOR ' , $ _SERVER )) {
55
- $ record ['context ' ]['IP ' ] = $ _SERVER ['HTTP_X_FORWARDED_FOR ' ];
56
- }
57
- $ record ['context ' ]['transactionID ' ] = uniqid ();
58
- if (array_key_exists ('CORRELATION_ID ' , $ _ENV )) {
59
- $ record ['context ' ]['correlationID ' ] = $ _ENV ['CORRELATION_ID ' ];
60
- }
61
- if (! env ('PLANROOM_HOST ' , false )) {
62
- $ record ['context ' ]['planroomHost ' ] = env ('PLANROOM_HOST ' );
63
- }
64
- return $ record ;
65
- });
66
- }
67
33
}
0 commit comments