Add a way to log commands

This commit is contained in:
Pierre Rudloff 2020-07-15 22:22:12 +02:00
parent dfdf6fef76
commit 0413427bbe
3 changed files with 74 additions and 51 deletions

View file

@ -14,6 +14,8 @@ use Alltube\Library\Exception\WrongPasswordException;
use Alltube\Library\Exception\YoutubedlException;
use GuzzleHttp\Client;
use Psr\Http\Message\ResponseInterface;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Symfony\Component\Process\Process;
/**
@ -65,6 +67,11 @@ class Downloader
*/
private $params;
/**
* @var LoggerInterface
*/
private $logger;
/**
* Downloader constructor.
* @param string $youtubedl youtube-dl binary path
@ -88,6 +95,17 @@ class Downloader
$this->avconv = $avconv;
$this->phantomjsDir = $phantomjsDir;
$this->avconvVerbosity = $avconvVerbosity;
$this->logger = new NullLogger();
}
/**
* @param LoggerInterface $logger
* @return void
*/
public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;
}
/**
@ -207,7 +225,10 @@ class Downloader
$arguments[] = '-user_agent';
$arguments[] = $video->getProp('dump-user-agent');
return new Process($arguments);
$process = new Process($arguments);
$this->logger->debug($process->getCommandLine());
return $process;
}
@ -226,6 +247,7 @@ class Downloader
$process = $this->getProcess($arguments);
//This is needed by the openload extractor because it runs PhantomJS
$process->setEnv(['PATH' => $this->phantomjsDir]);
$this->logger->debug($process->getCommandLine());
$process->run();
if (!$process->isSuccessful()) {
$errorOutput = trim($process->getErrorOutput());

View file

@ -4,9 +4,10 @@
"license": "GPL-3.0-only",
"homepage": "http://alltubedownload.net/",
"require": {
"ext-json": "*",
"guzzlehttp/guzzle": "^6.5",
"symfony/process": "^4.0|^5.0",
"ext-json": "*"
"psr/log": "^1.1",
"symfony/process": "^4.0|^5.0"
},
"require-dev": {
"phpro/grumphp": "^0.18.0",

96
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "e084bdaf7ed377ff4963c65d85513eca",
"content-hash": "9a53e4f77d715163307f6736896493b8",
"packages": [
{
"name": "guzzlehttp/guzzle",
@ -245,6 +245,53 @@
],
"time": "2016-08-06T14:39:51+00:00"
},
{
"name": "psr/log",
"version": "1.1.3",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
"reference": "0f73288fd15629204f9d42b7055f72dacbe811fc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc",
"reference": "0f73288fd15629204f9d42b7055f72dacbe811fc",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.1.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Log\\": "Psr/Log/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for logging libraries",
"homepage": "https://github.com/php-fig/log",
"keywords": [
"log",
"psr",
"psr-3"
],
"time": "2020-03-23T09:12:05+00:00"
},
{
"name": "ralouphie/getallheaders",
"version": "3.0.3",
@ -1559,53 +1606,6 @@
],
"time": "2019-01-08T18:20:26+00:00"
},
{
"name": "psr/log",
"version": "1.1.3",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
"reference": "0f73288fd15629204f9d42b7055f72dacbe811fc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc",
"reference": "0f73288fd15629204f9d42b7055f72dacbe811fc",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.1.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Log\\": "Psr/Log/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for logging libraries",
"homepage": "https://github.com/php-fig/log",
"keywords": [
"log",
"psr",
"psr-3"
],
"time": "2020-03-23T09:12:05+00:00"
},
{
"name": "roave/security-advisories",
"version": "dev-master",