Log.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Mtf\Util\Command\File;
  7. use Magento\Mtf\Util\Protocol\CurlTransport;
  8. /**
  9. * Get content of log file in var/log folder.
  10. */
  11. class Log
  12. {
  13. /**
  14. * Url to log.php.
  15. */
  16. const URL = 'dev/tests/functional/utils/log.php';
  17. /**
  18. * Curl transport protocol.
  19. *
  20. * @var CurlTransport
  21. */
  22. private $transport;
  23. /**
  24. * @param CurlTransport $transport
  25. */
  26. public function __construct(CurlTransport $transport)
  27. {
  28. $this->transport = $transport;
  29. }
  30. /**
  31. * Get content of log file in var/log folder by file name.
  32. *
  33. * @param string $name
  34. * @return array
  35. */
  36. public function getFileContent($name)
  37. {
  38. $curl = $this->transport;
  39. $curl->write($this->prepareUrl($name), [], CurlTransport::GET);
  40. $data = $curl->read();
  41. $curl->close();
  42. return unserialize($data);
  43. }
  44. /**
  45. * Prepare url.
  46. *
  47. * @param string $name
  48. * @return string
  49. */
  50. private function prepareUrl($name)
  51. {
  52. return $_ENV['app_frontend_url'] . self::URL . '?name=' . urlencode($name);
  53. }
  54. }