Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Commit

Permalink
feat(mqtt): debug mode for daemon
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry authored and DIOHz0r committed Feb 8, 2018
1 parent 73dbc94 commit 670bb6f
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions scripts/mqtt.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,33 @@
// Ensure current directory when run from crontab
chdir(dirname($_SERVER["SCRIPT_FILENAME"]));

if (isset($argv[1])) {
if ($argv[1] == '--tests') {
echo "running in testing environment" . PHP_EOL;
define('GLPI_ROOT', dirname(dirname(dirname(__DIR__))));
define("GLPI_CONFIG_DIR", GLPI_ROOT . "/tests");
}
include (__DIR__ . "/../vendor/docopt/docopt/src/docopt.php");

$doc = <<<DOC
cli_install.php
Usage:
cli_install.php [ --tests ] [ --debug ]
Options:
--tests Use GLPI test database
--debug Verbose mode for debug (dumps all messages)
DOC;

$docopt = new \Docopt\Handler();
$args = $docopt->handle($doc);
if (isset($args['--tests']) && $args['--tests'] !== false) {
echo "running in testing environment" . PHP_EOL;
define('GLPI_ROOT', dirname(dirname(dirname(__DIR__))));
define("GLPI_CONFIG_DIR", GLPI_ROOT . "/tests");
}

include (__DIR__ . '/../../../inc/includes.php');

if (isset($args['--debug']) && $args['--debug'] !== false) {
\sskaje\mqtt\Debug::Enable();
}
$mqttLogger = PluginFlyvemdmMqttclient::getInstance();
$mqttLogger->setHandler(PluginFlyvemdmMqtthandler::getInstance());
$mqttLogger->subscribe();

0 comments on commit 670bb6f

Please sign in to comment.