From eafea07d2c81098a464ae6747f08655c03224beb Mon Sep 17 00:00:00 2001 From: James Titcumb Date: Sat, 9 Nov 2019 13:54:38 +0200 Subject: [PATCH] Added additional debug logging to show connectivity details --- CHANGELOG.md | 2 ++ src/Agent.php | 18 +++++++++++++++--- tests/Unit/AgentTest.php | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f441b5c1..155e18e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ ### Changed + - Added more debug logging to isolate issues easier (#111) + ## [1.0.0] 2019-11-05 ### Changed diff --git a/src/Agent.php b/src/Agent.php index 8579b1f8..0adb993c 100644 --- a/src/Agent.php +++ b/src/Agent.php @@ -130,8 +130,17 @@ public static function fromConfig(Config $config, ?LoggerInterface $logger = nul public function connect() : void { - if (! $this->connector->connected() && $this->enabled()) { - $this->logger->info('Scout Core Agent Connection Failed, attempting to start'); + if (! $this->enabled()) { + $this->logger->debug('Connection skipped, since monitoring is disabled'); + + return; + } + + if (! $this->connector->connected()) { + $this->logger->info(sprintf( + 'Scout Core Agent (app=%s) not connected yet, attempting to start', + $this->config->get(ConfigKey::APPLICATION_NAME) + )); $manager = new AutomaticDownloadAndLaunchManager( $this->config, $this->logger, @@ -157,7 +166,10 @@ public function connect() : void $this->logger->warning($failedToConnect->getMessage()); } } else { - $this->logger->debug('Scout Core Agent Connected'); + $this->logger->debug(sprintf( + 'Scout Core Agent Connected (app=%s)', + $this->config->get(ConfigKey::APPLICATION_NAME) + )); } } diff --git a/tests/Unit/AgentTest.php b/tests/Unit/AgentTest.php index 6a114c9f..a016b240 100644 --- a/tests/Unit/AgentTest.php +++ b/tests/Unit/AgentTest.php @@ -119,7 +119,7 @@ public function testLogMessagesAreLoggedWhenUsingDefaultConfiguration() : void ->method('log') ->with( LogLevel::DEBUG, - self::stringContains('Scout Core Agent Connected'), + self::stringContains('Connection skipped, since monitoring is disabled'), [] );