File tree Expand file tree Collapse file tree 3 files changed +42
-4
lines changed Expand file tree Collapse file tree 3 files changed +42
-4
lines changed Original file line number Diff line number Diff line change 77
88use Graycore \GraphQlLogger \Api \LogRepositoryInterface ;
99use Graycore \GraphQlLogger \Api \Data \LogInterfaceFactory as LogFactory ;
10- use Magento \Framework \App \RequestInterface ;
1110use Magento \Framework \Exception \NoSuchEntityException ;
1211use Magento \Framework \Stdlib \DateTime \TimezoneInterface ;
1312
1413class Logger implements LoggerInterface
1514{
1615 private LogRepositoryInterface $ logRepository ;
1716 private LogFactory $ logFactory ;
18- private RequestInterface $ request ;
1917 private TimezoneInterface $ date ;
2018 private Config $ config ;
2119
2220 /**
2321 * @param Config $config
2422 */
2523 public function __construct (
26- RequestInterface $ request ,
2724 LogRepositoryInterface $ logRepository ,
2825 LogFactory $ logFactory ,
2926 TimezoneInterface $ date ,
@@ -54,7 +51,7 @@ public function execute(array $queryDetails)
5451 }
5552
5653 $ log ->setHash ($ hash )
57- ->setMethod ($ this -> request -> getMethod () )
54+ ->setMethod ($ queryDetails [LoggerInterface:: HTTP_METHOD ] )
5855 ->setQuery ($ queryDetails ['query ' ])
5956 ->setUpdated ($ this ->date ->date ()->format ('Y-m-d H:i:s ' ));
6057 $ this ->logRepository ->save ($ log );
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Graycore \GraphQlLogger \Logger ;
4+
5+ use Graycore \GraphQlLogger \Model \Config ;
6+ use Magento \Framework \App \RequestInterface ;
7+ use Magento \GraphQl \Helper \Query \Logger \LogData ;
8+
9+ class LogDataPlugin
10+ {
11+ private Config $ config ;
12+
13+ /**
14+ * @param Config $config
15+ */
16+ public function __construct (
17+ Config $ config
18+ ) {
19+ $ this ->config = $ config ;
20+ }
21+
22+ public function afterGetLogData (
23+ LogData $ logdata ,
24+ array $ result ,
25+ RequestInterface $ request ,
26+ array $ data
27+ ): array {
28+ if (!$ this ->config ->isEnabled ()) {
29+ return $ result ;
30+ }
31+
32+ /**
33+ * Add the query to the data.
34+ */
35+ $ result ['query ' ] = $ data ['query ' ];
36+ return $ result ;
37+ }
38+ }
Original file line number Diff line number Diff line change 1010 </argument >
1111 </arguments >
1212 </type >
13+ <type name =" Magento\GraphQl\Helper\Query\Logger\LogData" >
14+ <plugin name =" Graycore_GraphQlLogger::additionalLogData" type =" Graycore\GraphQlLogger\Plugin\LogDataPlugin" />
15+ </type >
1316</config >
You can’t perform that action at this time.
0 commit comments