diff --git a/CHANGELOG.md b/CHANGELOG.md index 339177b9..522dbcdf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Changed - Added `language_version` key to be sent with metadata (#110) + - Added more debug logging to isolate issues easier (#111) ## [1.0.0] 2019-11-05 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'), [] );