File tree 2 files changed +35
-2
lines changed
2 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -14,8 +14,9 @@ class LogResource extends JsonResource
14
14
public function toArray ($ request ): array
15
15
{
16
16
$ level = $ this ->getLevel ();
17
+ $ excludeFullText = $ request ->boolean ('exclude_full_text ' , false );
17
18
18
- return [
19
+ $ data = [
19
20
'index ' => $ this ->index ,
20
21
'file_identifier ' => $ this ->fileIdentifier ,
21
22
'file_position ' => $ this ->filePosition ,
@@ -30,8 +31,13 @@ public function toArray($request): array
30
31
'context ' => $ this ->context ,
31
32
'extra ' => $ this ->extra ,
32
33
33
- 'full_text ' => $ this ->getOriginalText (),
34
34
'url ' => $ this ->url (),
35
35
];
36
+
37
+ if (! $ excludeFullText ) {
38
+ $ data ['full_text ' ] = $ this ->getOriginalText ();
39
+ }
40
+
41
+ return $ data ;
36
42
}
37
43
}
Original file line number Diff line number Diff line change 61
61
]));
62
62
expect ($ response ->json ('logs ' ))->toHaveCount (4 );
63
63
});
64
+
65
+ test ('logs include full_text property by default ' , function () {
66
+ $ logEntries = [
67
+ makeLaravelLogEntry (message: 'Test message ' ),
68
+ ];
69
+ $ file = generateLogFile ('log_with_full_text.log ' , implode (PHP_EOL , $ logEntries ));
70
+
71
+ $ response = getJson (route ('log-viewer.logs ' , ['file ' => $ file ->identifier ]));
72
+
73
+ expect ($ response ->json ('logs ' ))->toHaveCount (1 );
74
+ expect ($ response ->json ('logs.0 ' ))->toHaveKey ('full_text ' );
75
+ });
76
+
77
+ test ('logs can exclude full_text property when requested ' , function () {
78
+ $ logEntries = [
79
+ makeLaravelLogEntry (message: 'Test message ' ),
80
+ ];
81
+ $ file = generateLogFile ('log_without_full_text.log ' , implode (PHP_EOL , $ logEntries ));
82
+
83
+ $ response = getJson (route ('log-viewer.logs ' , [
84
+ 'file ' => $ file ->identifier ,
85
+ 'exclude_full_text ' => true ,
86
+ ]));
87
+
88
+ expect ($ response ->json ('logs ' ))->toHaveCount (1 );
89
+ expect ($ response ->json ('logs.0 ' ))->not ->toHaveKey ('full_text ' );
90
+ });
You can’t perform that action at this time.
0 commit comments