From 5b9716f453dc94ba070b4ffdbb3a11c9d8c5a38f Mon Sep 17 00:00:00 2001 From: Darin Howard Date: Wed, 28 Nov 2018 16:19:48 -0600 Subject: [PATCH 01/24] RT-1844 - adding in logServerVariables toggle (defaults to disabled) --- .gitignore | 1 + README.md | 39 +++++++++++++++++++++++----- composer.json | 6 +++-- src/Stackify/Log/Monolog/Handler.php | 8 +++--- 4 files changed, 42 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 7579f74..fa36fe5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ vendor composer.lock +.idea diff --git a/README.md b/README.md index b3ca226..bf7c6bd 100644 --- a/README.md +++ b/README.md @@ -66,18 +66,27 @@ monolog: #### Optional Configuration -Proxy +**Proxy** - ExecTransport supports data delivery through proxy. Specify proxy using [libcurl format](http://curl.haxx.se/libcurl/c/CURLOPT_PROXY.html): <[protocol://][user:password@]proxyhost[:port]> ```php $transport = new ExecTransport($apiKey, ['proxy' => 'https://55.88.22.11:3128']); ``` -Curl path +**Curl path** - It can be useful to specify ```curl``` destination path for ExecTransport. This option is set to 'curl' by default. ```php $transport = new ExecTransport($apiKey, ['curlPath' => '/usr/bin/curl']); ``` +**Log Server Environment Variables** +- Server environment variables can be added to error log message metadata. **Note:** This will log all +system environment variables; do not enable if sensitive information such as passwords or keys are stored this way. + + ```php +$handler = new StackifyHandler('application_name', 'environment_name', $transport, true); +``` + + ### CurlTransport CurlTransport does not require a Stackify agent to be installed and it also sends data directly to Stackify services. It collects log entries in a single batch and sends data using native [PHP cURL](http://php.net/manual/en/book.curl.php) functions. This way is a blocking one, so it should not be used on production environments. To configure CurlTransport you need to pass environment name and API key (license key): @@ -111,12 +120,20 @@ monolog: #### Optional Configuration -Proxy +**Proxy** - CurlTransport supports data delivery through proxy. Specify proxy using [libcurl format](http://curl.haxx.se/libcurl/c/CURLOPT_PROXY.html): <[protocol://][user:password@]proxyhost[:port]> ```php $transport = new CurlTransport($apiKey, ['proxy' => 'https://55.88.22.11:3128']); ``` +**Log Server Environment Variables** +- Server environment variables can be added to error log message metadata. **Note:** This will log all +system environment variables; do not enable if sensitive information such as passwords or keys are stored this way. + + ```php +$handler = new StackifyHandler('application_name', 'environment_name', $transport, true); +``` + ### AgentTransport AgentTransport does not require additional configuration in your PHP code because all data is passed to the [Stackify agent](https://stackify.screenstepslive.com/s/3095/m/7787/l/119709-installation-for-linux). The agent must be installed on the same machine. Local TCP socket on port 10515 is used, so performance of your application is affected minimally. @@ -126,7 +143,7 @@ PHP: use Monolog\Logger; use Stackify\Log\Monolog\Handler as StackifyHandler; -$handler = new StackifyHandler('application_name'); +$handler = new StackifyHandler('application_name', 'environment_name'); $logger = new Logger('logger'); $logger->pushHandler($handler); ``` @@ -136,7 +153,7 @@ Symfony: services: stackify_handler: class: "Stackify\\Log\\Monolog\\Handler" - arguments: ["application_name"] + arguments: ["application_name", "environment_name"] monolog: handlers: stackify: @@ -146,6 +163,16 @@ monolog: You will need to enable the TCP listener by checking the "PHP App Logs (Agent Log Collector)" in the server settings page in Stackify. See [Log Collectors Page](http://docs.stackify.com/m/7787/l/302705-log-collectors) for more details. +#### Optional Settings + +**Log Server Environment Variables** +- Server environment variables can be added to error log message metadata. **Note:** This will log all +system environment variables; do not enable if sensitive information such as passwords or keys are stored this way. + + ```php +$handler = new StackifyHandler('application_name', 'environment_name', null, true); +``` + ## Notes To get more error details pass Exception objects to the logger if available: @@ -167,7 +194,7 @@ $transport = new ExecTransport($apiKey, ['debug' => true]); ## License -Copyright 2015 Stackify, LLC. +Copyright 2018 Stackify, LLC. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/composer.json b/composer.json index b9c2e47..beb0d77 100644 --- a/composer.json +++ b/composer.json @@ -6,12 +6,14 @@ "type": "library", "license": "Apache-2.0", "require": { - "stackify/logger": "~1.0", + "stackify/logger": "~1.1", "monolog/monolog": "~1.1" }, "autoload": { "psr-4": { "Stackify\\Log\\Monolog\\": "src/Stackify/Log/Monolog" } - } + }, + "minimum-stability": "dev", + "prefer-stable": true } diff --git a/src/Stackify/Log/Monolog/Handler.php b/src/Stackify/Log/Monolog/Handler.php index 3baa270..96a90e6 100644 --- a/src/Stackify/Log/Monolog/Handler.php +++ b/src/Stackify/Log/Monolog/Handler.php @@ -17,10 +17,10 @@ class Handler extends AbstractHandler */ private $transport; - public function __construct($appName, $environmentName = null, TransportInterface $transport = null, $level = Logger::DEBUG, $bubble = true) + public function __construct($appName, $environmentName = null, TransportInterface $transport = null, $logServerVariables = false, $level = Logger::DEBUG, $bubble = true) { parent::__construct($level, $bubble); - $messageBuilder = new MessageBuilder('Stackify Monolog v.1.0', $appName, $environmentName); + $messageBuilder = new MessageBuilder('Stackify Monolog v.1.0', $appName, $environmentName, $logServerVariables); if (null === $transport) { $transport = new AgentTransport(); } @@ -36,7 +36,7 @@ public function handle(array $record) if (!$this->isHandling($record)) { return false; } - + $logEntry = new LogEntry($record); $this->transport->addEntry($logEntry); @@ -52,4 +52,4 @@ public function close() $this->transport->finish(); } -} \ No newline at end of file +} From e2454459fbe4edfa9368dbbf30b50cb5e143a5f9 Mon Sep 17 00:00:00 2001 From: Todd Lair Date: Thu, 2 Sep 2021 16:26:45 -0500 Subject: [PATCH 02/24] Set up CI with Azure Pipelines [skip ci] --- azure-pipelines.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 azure-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..767c08c --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,34 @@ +# PHP +# Test and package your PHP project. +# Add steps that run tests, save build artifacts, deploy, and more: +# https://docs.microsoft.com/azure/devops/pipelines/languages/php + +trigger: +- master + +pool: + vmImage: ubuntu-latest + +variables: + phpVersion: 7.2 + +steps: +- script: | + sudo update-alternatives --set php /usr/bin/php$(phpVersion) + sudo update-alternatives --set phar /usr/bin/phar$(phpVersion) + sudo update-alternatives --set phpdbg /usr/bin/phpdbg$(phpVersion) + sudo update-alternatives --set php-cgi /usr/bin/php-cgi$(phpVersion) + sudo update-alternatives --set phar.phar /usr/bin/phar.phar$(phpVersion) + php -version + displayName: 'Use PHP version $(phpVersion)' + +- script: composer install --no-interaction --prefer-dist + displayName: 'composer install' +- task: CmdLine@2 + inputs: + script: 'curl -sSL https://www.sourceclear.com/install | sh' +- task: CmdLine@2 + inputs: + script: 'srcclr scan .' + env: + SRCCLR_API_TOKEN: $(SRCCLR_API_TOKEN) \ No newline at end of file From 34991eb62391f367cfe35432eff2115be6e94fad Mon Sep 17 00:00:00 2001 From: Todd Lair Date: Thu, 9 Sep 2021 09:46:52 -0500 Subject: [PATCH 03/24] Added veracode upload step --- azure-pipelines.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 767c08c..c7c3990 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -31,4 +31,15 @@ steps: inputs: script: 'srcclr scan .' env: - SRCCLR_API_TOKEN: $(SRCCLR_API_TOKEN) \ No newline at end of file + SRCCLR_API_TOKEN: $(SRCCLR_API_TOKEN) +- task: CmdLine@2 + inputs: + script: 'zip -r stackify-log-monolog.zip src/ composer.json' +- task: Veracode@3 + inputs: + ConnectionDetailsSelection: 'Endpoint' + AnalysisService: 'Veracode' + veracodeAppProfile: 'Retrace PHP Monolog library' + version: 'AZ-Devops-Build-$(build.buildNumber)' + filepath: 'stackify-log-monolog.zip' + maximumWaitTime: '360' \ No newline at end of file From b059132c5338dd8fe6aaedceabbd41fee1e2606b Mon Sep 17 00:00:00 2001 From: Todd Lair Date: Wed, 24 Nov 2021 10:53:07 -0600 Subject: [PATCH 04/24] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index c7c3990..c3645a3 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -6,6 +6,14 @@ trigger: - master +schedules: +- cron: "0 21-22 31 * *" + displayName: Monthly build + branches: + include: + - develop + always: true + pool: vmImage: ubuntu-latest From eb7b4924dff613ca8386242e15900f51245dd38f Mon Sep 17 00:00:00 2001 From: Michael Mantos Date: Wed, 5 Jan 2022 10:30:32 +0800 Subject: [PATCH 05/24] PHP-17 - Add flush on reset/close for handler --- src/Stackify/Log/Monolog/Handler.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/Stackify/Log/Monolog/Handler.php b/src/Stackify/Log/Monolog/Handler.php index a567ad8..cdc1fcc 100644 --- a/src/Stackify/Log/Monolog/Handler.php +++ b/src/Stackify/Log/Monolog/Handler.php @@ -67,6 +67,16 @@ public function write(array $record): void $this->_transport->addEntry(new LogEntry($record)); } + /** + * Flush logs to API + * + * @return void + */ + public function flush() + { + $this->_transport->finish(); + } + /** * {@inheritdoc} * @@ -74,7 +84,18 @@ public function write(array $record): void */ public function close(): void { + $this->flush(); parent::close(); - $this->_transport->finish(); + } + + /** + * {@inheritdoc} + * + * @return void + */ + public function reset() + { + $this->flush(); + parent::reset(); } } From dbcddcd1210f749bf63341fd372ce472f2502148 Mon Sep 17 00:00:00 2001 From: Todd Lair Date: Wed, 5 Jan 2022 12:47:31 -0600 Subject: [PATCH 06/24] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index c3645a3..d00c434 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -34,7 +34,7 @@ steps: displayName: 'composer install' - task: CmdLine@2 inputs: - script: 'curl -sSL https://www.sourceclear.com/install | sh' + script: 'curl -sSL https://www.sourceclear.com/install | bash' - task: CmdLine@2 inputs: script: 'srcclr scan .' From d5ff1c6102a7c1ae3d0a3e89af33040255b3edc6 Mon Sep 17 00:00:00 2001 From: Todd Lair <26470949+t-lair@users.noreply.github.com> Date: Mon, 11 Apr 2022 09:17:58 -0500 Subject: [PATCH 07/24] Updated the branch for the scheduled Veracode build --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d00c434..102e586 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -11,7 +11,7 @@ schedules: displayName: Monthly build branches: include: - - develop + - master always: true pool: From 8049948f89714dc29422c686a392e021a2984919 Mon Sep 17 00:00:00 2001 From: Todd Lair <26470949+t-lair@users.noreply.github.com> Date: Fri, 19 Aug 2022 14:33:20 -0500 Subject: [PATCH 08/24] Update build schedule to weekly --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 102e586..34aeec7 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -7,8 +7,8 @@ trigger: - master schedules: -- cron: "0 21-22 31 * *" - displayName: Monthly build +- cron: "0 21-22 * * 0" + displayName: Weekly build branches: include: - master From c3184596ca5edf7b5072daf116bb7de60e98a382 Mon Sep 17 00:00:00 2001 From: Todd Lair <26470949+t-lair@users.noreply.github.com> Date: Thu, 1 Jun 2023 08:14:39 -0500 Subject: [PATCH 09/24] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 34aeec7..7cf03b4 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -42,7 +42,7 @@ steps: SRCCLR_API_TOKEN: $(SRCCLR_API_TOKEN) - task: CmdLine@2 inputs: - script: 'zip -r stackify-log-monolog.zip src/ composer.json' + script: 'zip -r stackify-log-monolog.zip src/Stackify/Log/Monolog/Handler.php src/Stackify/Log/Monolog/LogEntry.php composer.json' - task: Veracode@3 inputs: ConnectionDetailsSelection: 'Endpoint' From 2a367cfcb72354b4e5b58acf6b01bb1376be65d1 Mon Sep 17 00:00:00 2001 From: Todd Lair <26470949+t-lair@users.noreply.github.com> Date: Thu, 1 Jun 2023 08:49:55 -0500 Subject: [PATCH 10/24] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 7cf03b4..230de04 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -40,6 +40,22 @@ steps: script: 'srcclr scan .' env: SRCCLR_API_TOKEN: $(SRCCLR_API_TOKEN) + +- task: CmdLine@2 + displayName: 'Make Directory' + inputs: + script: 'mkdir test' + +- task: CmdLine@2 + displayName: 'Copy Files' + inputs: + script: 'cp src/Stackify/Log/Monolog/Handler.php test && cp src/Stackify/Log/Monolog/LogEntry.php test && cp composer.json test' + +- task: CmdLine@2 + displayName: 'Make test zip' + inputs: + script: 'zip -r stackify-log-monolog-test.zip test' + - task: CmdLine@2 inputs: script: 'zip -r stackify-log-monolog.zip src/Stackify/Log/Monolog/Handler.php src/Stackify/Log/Monolog/LogEntry.php composer.json' @@ -49,5 +65,5 @@ steps: AnalysisService: 'Veracode' veracodeAppProfile: 'Retrace PHP Monolog library' version: 'AZ-Devops-Build-$(build.buildNumber)' - filepath: 'stackify-log-monolog.zip' + filepath: 'stackify-log-monolog-test.zip' maximumWaitTime: '360' \ No newline at end of file From d62317c3cbe7ec0cdbd58e226692d063f73b2b33 Mon Sep 17 00:00:00 2001 From: Todd Lair <26470949+t-lair@users.noreply.github.com> Date: Thu, 1 Jun 2023 08:59:41 -0500 Subject: [PATCH 11/24] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 230de04..a94a6af 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -40,30 +40,23 @@ steps: script: 'srcclr scan .' env: SRCCLR_API_TOKEN: $(SRCCLR_API_TOKEN) - - task: CmdLine@2 displayName: 'Make Directory' inputs: - script: 'mkdir test' - + script: 'mkdir temp' - task: CmdLine@2 displayName: 'Copy Files' inputs: - script: 'cp src/Stackify/Log/Monolog/Handler.php test && cp src/Stackify/Log/Monolog/LogEntry.php test && cp composer.json test' - -- task: CmdLine@2 - displayName: 'Make test zip' - inputs: - script: 'zip -r stackify-log-monolog-test.zip test' - + script: 'cp src/Stackify/Log/Monolog/Handler.php temp && cp src/Stackify/Log/Monolog/LogEntry.php temp && cp composer.json temp' - task: CmdLine@2 + displayName: 'Make zip' inputs: - script: 'zip -r stackify-log-monolog.zip src/Stackify/Log/Monolog/Handler.php src/Stackify/Log/Monolog/LogEntry.php composer.json' + script: 'zip -r stackify-log-monolog.zip temp' - task: Veracode@3 inputs: ConnectionDetailsSelection: 'Endpoint' AnalysisService: 'Veracode' veracodeAppProfile: 'Retrace PHP Monolog library' version: 'AZ-Devops-Build-$(build.buildNumber)' - filepath: 'stackify-log-monolog-test.zip' + filepath: 'stackify-log-monolog.zip' maximumWaitTime: '360' \ No newline at end of file From cd928ead6c92a532506eeaab0ab0520ffd1bc9f8 Mon Sep 17 00:00:00 2001 From: homiedopie Date: Tue, 28 Nov 2023 00:44:39 +0800 Subject: [PATCH 12/24] Add Monolog v3 Support --- composer.json | 6 +++--- src/Stackify/Log/Monolog/Handler.php | 27 +++++++++++++++------------ src/Stackify/Log/Monolog/LogEntry.php | 3 ++- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/composer.json b/composer.json index 5e314f2..3e38df0 100644 --- a/composer.json +++ b/composer.json @@ -6,9 +6,9 @@ "type": "library", "license": "Apache-2.0", "require": { - "php": ">=7.0", - "stackify/logger": "~1.4", - "monolog/monolog": "~2.0" + "php": ">=8.1", + "stackify/logger": "~2.0", + "monolog/monolog": "~3.0" }, "autoload": { "psr-4": { diff --git a/src/Stackify/Log/Monolog/Handler.php b/src/Stackify/Log/Monolog/Handler.php index cdc1fcc..bc24711 100644 --- a/src/Stackify/Log/Monolog/Handler.php +++ b/src/Stackify/Log/Monolog/Handler.php @@ -8,6 +8,8 @@ use Monolog\Logger; use Monolog\Handler\AbstractProcessingHandler; +use Monolog\Level; +use Monolog\LogRecord; class Handler extends AbstractProcessingHandler { @@ -16,7 +18,7 @@ class Handler extends AbstractProcessingHandler * * @var \Stackify\Log\Transport\TransportInterface */ - private $_transport; + private TransportInterface $_transport; /** * Stackify monolog handler @@ -29,14 +31,15 @@ class Handler extends AbstractProcessingHandler * @param boolean $bubble */ public function __construct( - $appName, - $environmentName = null, + string $appName, + string $environmentName = null, TransportInterface $transport = null, - $logServerVariables = false, - $config = null, - $level = Logger::DEBUG, - $bubble = true + bool $logServerVariables = false, + array $config = null, + int|string|Level $level = Level::Debug, + bool $bubble = true ) { + parent::__construct($level, $bubble); if ($config) { @@ -45,7 +48,7 @@ public function __construct( AgentConfig::getInstance()->extract($config); } - $messageBuilder = new MessageBuilder('Stackify Monolog v.2.0', $appName, $environmentName, $logServerVariables); + $messageBuilder = new MessageBuilder('Stackify Monolog v.3.0', $appName, $environmentName, $logServerVariables); if (null === $transport) { $transport = new AgentSocketTransport(); @@ -58,11 +61,11 @@ public function __construct( /** * {@inheritdoc} * - * @param array $record + * @param LogRecord $record * * @return void */ - public function write(array $record): void + public function write(LogRecord $record): void { $this->_transport->addEntry(new LogEntry($record)); } @@ -72,7 +75,7 @@ public function write(array $record): void * * @return void */ - public function flush() + public function flush(): void { $this->_transport->finish(); } @@ -93,7 +96,7 @@ public function close(): void * * @return void */ - public function reset() + public function reset(): void { $this->flush(); parent::reset(); diff --git a/src/Stackify/Log/Monolog/LogEntry.php b/src/Stackify/Log/Monolog/LogEntry.php index 6041349..a162e1f 100644 --- a/src/Stackify/Log/Monolog/LogEntry.php +++ b/src/Stackify/Log/Monolog/LogEntry.php @@ -6,6 +6,7 @@ use Stackify\Log\Entities\NativeError; use Monolog\Logger as MonologLogger; +use Monolog\LogRecord as MonologLogRecord; final class LogEntry implements LogEntryInterface { @@ -15,7 +16,7 @@ final class LogEntry implements LogEntryInterface private $context; private $nativeError; - public function __construct(array $record) + public function __construct(MonologLogRecord $record) { $this->record = $record; $context = $record['context']; From a9dcaec508687790e31fa2a76dcf00ff5ec70ae2 Mon Sep 17 00:00:00 2001 From: homiedopie Date: Tue, 28 Nov 2023 00:48:02 +0800 Subject: [PATCH 13/24] Update README --- README.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8138932..9fb38a4 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,16 @@ -# Stackify Monolog v2 Handler +# Stackify Monolog v3 Handler Monolog handler for sending log messages and exceptions to Stackify. -Monolog >= 2.0.0 is supported. +Monolog >= 3.0.0 is supported. -> For Monolog v1, use the [1.x branch](https://github.com/stackify/stackify-log-monolog/tree/1.x) +For Monolog V1 + +> Use the [1.x branch](https://github.com/stackify/stackify-log-monolog/tree/1.x) + +For Monolog V2 + +> Use the [2.x branch](https://github.com/stackify/stackify-log-monolog/tree/2.x) * **Errors and Logs Overview:** http://support.stackify.com/errors-and-logs-overview/ * **Sign Up for a Trial:** http://www.stackify.com/sign-up/ From 420e4aff4a44940cd78c109b8648cd0c3a7f1359 Mon Sep 17 00:00:00 2001 From: Michael Mantos Date: Wed, 20 Dec 2023 22:09:47 +0800 Subject: [PATCH 14/24] RTRACE-45: Add some test cases --- .gitignore | 4 ++ composer.json | 9 ++++ phpunit.xml.dist | 8 ++++ tests/HandlerTest.php | 108 ++++++++++++++++++++++++++++++++++++++++++ tests/bootstrap.php | 3 ++ 5 files changed, 132 insertions(+) create mode 100644 phpunit.xml.dist create mode 100644 tests/HandlerTest.php create mode 100644 tests/bootstrap.php diff --git a/.gitignore b/.gitignore index fa36fe5..5d0d27a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ vendor composer.lock .idea +*.iml +phpunit.xml +*.cache +*.bak \ No newline at end of file diff --git a/composer.json b/composer.json index 3e38df0..4ef9022 100644 --- a/composer.json +++ b/composer.json @@ -10,9 +10,18 @@ "stackify/logger": "~2.0", "monolog/monolog": "~3.0" }, + "require-dev": { + "phpstan/phpstan": "^1.9", + "phpstan/phpstan-deprecation-rules": "^1.0", + "phpstan/phpstan-strict-rules": "^1.4", + "phpunit/phpunit": "^10.1" + }, "autoload": { "psr-4": { "Stackify\\Log\\Monolog\\": "src/Stackify/Log/Monolog" + }, + "autoload-dev": { + "psr-4": {"Stackify\\Log\\Monolog\\Tests": "tests/"} } }, "minimum-stability": "dev", diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..64292b9 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,8 @@ + + + + + ./tests + + + diff --git a/tests/HandlerTest.php b/tests/HandlerTest.php new file mode 100644 index 0000000..06c10c3 --- /dev/null +++ b/tests/HandlerTest.php @@ -0,0 +1,108 @@ + [$level], + Level::cases() + ); + } + + /** + * @dataProvider logLevelProvider + */ + public function testHandlesAllLevels(Level $level) + { + $message = 'Hello, world! ' . $level->value; + $context = ['foo' => 'bar', 'level' => $level->value]; + + $transport = $this->createDummyTransport(); + + $handler = $this->createDummyHandler($transport, $level); + $record = $this->getRecord($level, $message, context: $context); + $handler->handle($record); + + $logEntries = $transport->getEntries(); + + $firstLogEntry = $logEntries[0]; + + $this->assertEquals(1, count($logEntries)); + $this->assertEquals($firstLogEntry->getLevel(), strtoupper($record->level->name)); + $this->assertEquals($firstLogEntry->getMessage(), $record->message); + + // Reset every call + $transport->reset(); + } + + private function createDummyHandler($transport, Level $level = null) { + return $this->createHandler($this->appName, $this->environmentName, $transport, $level); + } + + private function createHandler($appName, $environmentName, $transport, Level $level = null): Handler + { + if (null === $level) { + $handler = new Handler($appName, $environmentName, $transport, false, null, $level); + } else { + $handler = new Handler($appName, $environmentName, $transport); + } + + return $handler; + } + + private function createDummyTransport() + { + return new SpyTransport(); + } +} + + +class SpyTransport implements TransportInterface { + protected BuilderInterface $messageBuilder; + protected array $logEntries; + protected bool $hasFinished; + + public function __construct() { + $this->logEntries = []; + $this->hasFinished = false; + } + + public function setMessageBuilder(BuilderInterface $messageBuilder) { + $this->messageBuilder = $messageBuilder; + } + + public function addEntry(LogEntryInterface $logEntry): int { + $this->logEntries[] = $logEntry; + return count($this->logEntries) - 1; + } + + public function finish() { + $this->hasFinished = true; + } + + public function hasFinish() { + return $this->hasFinished; + } + + public function getEntries() { + return $this->logEntries; + } + + public function reset() { + $this->logEntries = []; + $this->hasFinished = false; + } +} diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100644 index 0000000..f091c14 --- /dev/null +++ b/tests/bootstrap.php @@ -0,0 +1,3 @@ + Date: Wed, 20 Dec 2023 22:30:07 +0800 Subject: [PATCH 15/24] RTRACE-45: Add channel to message --- src/Stackify/Log/Monolog/Handler.php | 12 +++++++- src/Stackify/Log/Monolog/LogEntry.php | 15 +++++++++- tests/HandlerTest.php | 41 +++++++++++++++++++++++---- 3 files changed, 61 insertions(+), 7 deletions(-) diff --git a/src/Stackify/Log/Monolog/Handler.php b/src/Stackify/Log/Monolog/Handler.php index bc24711..5cd779d 100644 --- a/src/Stackify/Log/Monolog/Handler.php +++ b/src/Stackify/Log/Monolog/Handler.php @@ -20,6 +20,11 @@ class Handler extends AbstractProcessingHandler */ private TransportInterface $_transport; + /** + * Include channel inside message as hashtag + */ + private bool $includeChannel; + /** * Stackify monolog handler * @@ -56,6 +61,11 @@ public function __construct( $transport->setMessageBuilder($messageBuilder); $this->_transport = $transport; + $this->includeChannel = false; + + if ($config && $config['includeChannel']) { + $this->includeChannel = true; + } } /** @@ -67,7 +77,7 @@ public function __construct( */ public function write(LogRecord $record): void { - $this->_transport->addEntry(new LogEntry($record)); + $this->_transport->addEntry(new LogEntry($record, $this->includeChannel)); } /** diff --git a/src/Stackify/Log/Monolog/LogEntry.php b/src/Stackify/Log/Monolog/LogEntry.php index a162e1f..4b5fef9 100644 --- a/src/Stackify/Log/Monolog/LogEntry.php +++ b/src/Stackify/Log/Monolog/LogEntry.php @@ -15,10 +15,13 @@ final class LogEntry implements LogEntryInterface private $exception; private $context; private $nativeError; + private $includeChannel; + private $channel; - public function __construct(MonologLogRecord $record) + public function __construct(MonologLogRecord $record, bool $includeChannel = false) { $this->record = $record; + $context = $record['context']; // find exception and remove from context foreach ($context as $key => $value) { @@ -45,6 +48,12 @@ public function __construct(MonologLogRecord $record) if (!empty($context)) { $this->context = $context; } + + $this->includeChannel = $includeChannel; + $this->channel = null; + if ($record && $record['channel']) { + $this->channel = $record['channel']; + } } public function getContext() @@ -64,6 +73,10 @@ public function getLevel() public function getMessage() { + if ($this->includeChannel && $this->channel) { + return $this->record['message']." #{$this->channel}"; + } + return $this->record['message']; } diff --git a/tests/HandlerTest.php b/tests/HandlerTest.php index 06c10c3..377446e 100644 --- a/tests/HandlerTest.php +++ b/tests/HandlerTest.php @@ -4,6 +4,7 @@ use Monolog\Level; use Monolog\Test\TestCase; +use Psr\Log\LogLevel; use Stackify\Log\Builder\BuilderInterface; use Stackify\Log\Entities\LogEntryInterface; use Stackify\Log\Monolog\Handler; @@ -48,16 +49,46 @@ public function testHandlesAllLevels(Level $level) $transport->reset(); } - private function createDummyHandler($transport, Level $level = null) { - return $this->createHandler($this->appName, $this->environmentName, $transport, $level); + public function testLogRecordChannel() + { + $level = Level::Info; + $message = 'Hello, world! ' . $level->value; + $context = ['foo' => 'bar', 'level' => $level->value]; + + $transport = $this->createDummyTransport(); + + $includeChannel = true; + $channel = "test"; + $handler = $this->createDummyHandler($transport, $level, $includeChannel); + $record = $this->getRecord($level, $message, context: $context, channel: $channel); + $handler->handle($record); + + $logEntries = $transport->getEntries(); + + $firstLogEntry = $logEntries[0]; + $this->assertEquals(1, count($logEntries)); + $this->assertEquals($firstLogEntry->getLevel(), strtoupper($record->level->name)); + $this->assertEquals($firstLogEntry->getMessage(), $record->message . " #{$channel}"); + + // Reset every call + $transport->reset(); + } + + private function createDummyHandler($transport, Level $level = null, $includeChannel = false) { + return $this->createHandler($this->appName, $this->environmentName, $transport, $level, $includeChannel); } - private function createHandler($appName, $environmentName, $transport, Level $level = null): Handler + private function createHandler($appName, $environmentName, $transport, Level $level = null, bool $includeChannel = false): Handler { + $config = []; + if ($includeChannel) { + $config['includeChannel'] = true; + } + if (null === $level) { - $handler = new Handler($appName, $environmentName, $transport, false, null, $level); + $handler = new Handler($appName, $environmentName, $transport, false, $config, $level); } else { - $handler = new Handler($appName, $environmentName, $transport); + $handler = new Handler($appName, $environmentName, $transport, false, $config); } return $handler; From 08f040a164f29f606e64c8777050bb55f6583949 Mon Sep 17 00:00:00 2001 From: Michael Mantos Date: Wed, 20 Dec 2023 23:08:07 +0800 Subject: [PATCH 16/24] RTRACE-45: Update composer for pipeline testing --- azure-pipelines.yml | 2 +- composer.json | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a94a6af..4be7f02 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -18,7 +18,7 @@ pool: vmImage: ubuntu-latest variables: - phpVersion: 7.2 + phpVersion: 8.1 steps: - script: | diff --git a/composer.json b/composer.json index 4ef9022..c4ea2d7 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "license": "Apache-2.0", "require": { "php": ">=8.1", - "stackify/logger": "~2.0", + "stackify/logger": "dev-feature/psr-log-2-3 as 2.0", "monolog/monolog": "~3.0" }, "require-dev": { @@ -24,6 +24,12 @@ "psr-4": {"Stackify\\Log\\Monolog\\Tests": "tests/"} } }, + "repositories": [ + { + "type": "vcs", + "url": "git@github.com:homiedopie/stackify-api-php.git" + } + ], "minimum-stability": "dev", "prefer-stable": true } From 20833300305caddf98abb51243303ef3f94664e9 Mon Sep 17 00:00:00 2001 From: Michael Mantos Date: Thu, 21 Dec 2023 00:03:01 +0800 Subject: [PATCH 17/24] RTRACE-45: Remove untrusted dependency and update stackify/logger version --- composer.json | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/composer.json b/composer.json index c4ea2d7..e19f00c 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "license": "Apache-2.0", "require": { "php": ">=8.1", - "stackify/logger": "dev-feature/psr-log-2-3 as 2.0", + "stackify/logger": "~1.6", "monolog/monolog": "~3.0" }, "require-dev": { @@ -24,12 +24,6 @@ "psr-4": {"Stackify\\Log\\Monolog\\Tests": "tests/"} } }, - "repositories": [ - { - "type": "vcs", - "url": "git@github.com:homiedopie/stackify-api-php.git" - } - ], "minimum-stability": "dev", "prefer-stable": true } From b64939d2e88f98d6c2c5de1abe8fbfdbf29120c5 Mon Sep 17 00:00:00 2001 From: Michael Mantos Date: Thu, 21 Dec 2023 01:22:12 +0800 Subject: [PATCH 18/24] RTRACE-45: Fix undefined index warning --- src/Stackify/Log/Monolog/Handler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Stackify/Log/Monolog/Handler.php b/src/Stackify/Log/Monolog/Handler.php index 5cd779d..bdc7371 100644 --- a/src/Stackify/Log/Monolog/Handler.php +++ b/src/Stackify/Log/Monolog/Handler.php @@ -63,7 +63,7 @@ public function __construct( $this->_transport = $transport; $this->includeChannel = false; - if ($config && $config['includeChannel']) { + if ($config && array_key_exists('includeChannel', $config) && $config['includeChannel']) { $this->includeChannel = true; } } From 75baa241466141e50dde5471f92d3adb523419ba Mon Sep 17 00:00:00 2001 From: Michael Mantos Date: Thu, 21 Dec 2023 02:50:45 +0800 Subject: [PATCH 19/24] RTRACE-45: Fix channel and make it kebab case --- README.md | 20 ++++++++++++++++++++ src/Stackify/Log/Monolog/Handler.php | 2 +- src/Stackify/Log/Monolog/LogEntry.php | 20 +++++++++++++++++++- tests/HandlerTest.php | 27 ++++++++++++++++++++++++++- 4 files changed, 66 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9fb38a4..05d3275 100644 --- a/README.md +++ b/README.md @@ -166,6 +166,26 @@ $handler = new StackifyHandler('application_name', 'environment_name', $transpor $logger = new Logger('logger'); $logger->pushHandler($handler); ``` +#### Handler Level Option +- **Include Channel** + - This will include the logger name or the channel set for the log entry. + + ```php +use Monolog\Logger; +use Stackify\Log\Monolog\Handler as StackifyHandler; + +$transport = new ExecTransport($apiKey); // Your selected transport (Can be null which defaults to AgentSocketTransport) +$logServerVariables = false; // Default +$config = array( + 'IncludeChannel' => true, + ... +); + +$handler = new StackifyHandler('application_name', 'environment_name', $transport, $logServerVariables, $config); +$logger = new Logger('logger'); +$logger->pushHandler($handler); +``` + ### Symfony ```yml services: diff --git a/src/Stackify/Log/Monolog/Handler.php b/src/Stackify/Log/Monolog/Handler.php index bdc7371..ad37dc8 100644 --- a/src/Stackify/Log/Monolog/Handler.php +++ b/src/Stackify/Log/Monolog/Handler.php @@ -63,7 +63,7 @@ public function __construct( $this->_transport = $transport; $this->includeChannel = false; - if ($config && array_key_exists('includeChannel', $config) && $config['includeChannel']) { + if ($config && array_key_exists('IncludeChannel', $config) && $config['IncludeChannel']) { $this->includeChannel = true; } } diff --git a/src/Stackify/Log/Monolog/LogEntry.php b/src/Stackify/Log/Monolog/LogEntry.php index 4b5fef9..ad25b8d 100644 --- a/src/Stackify/Log/Monolog/LogEntry.php +++ b/src/Stackify/Log/Monolog/LogEntry.php @@ -17,6 +17,7 @@ final class LogEntry implements LogEntryInterface private $nativeError; private $includeChannel; private $channel; + private static $kebabCache = []; public function __construct(MonologLogRecord $record, bool $includeChannel = false) { @@ -74,7 +75,7 @@ public function getLevel() public function getMessage() { if ($this->includeChannel && $this->channel) { - return $this->record['message']." #{$this->channel}"; + return $this->record['message']." #{$this->kebabCase($this->channel)}"; } return $this->record['message']; @@ -103,4 +104,21 @@ public function isErrorLevel() return $this->record['level'] >= MonologLogger::ERROR; } + + private function kebabCase($value = '') + { + $key = $value; + $delimiter = '-'; + + if (isset(static::$kebabCache[$key][$delimiter])) { + return static::$kebabCache[$key][$delimiter]; + } + + if (! ctype_lower($value)) { + $value = preg_replace('/\s+/u', '', ucwords($value)); + $value = strtolower(preg_replace('/(.)(?=[A-Z])/u', '$1'.$delimiter, $value)); + } + + return static::$kebabCache[$key][$delimiter] = $value; + } } \ No newline at end of file diff --git a/tests/HandlerTest.php b/tests/HandlerTest.php index 377446e..06a0e63 100644 --- a/tests/HandlerTest.php +++ b/tests/HandlerTest.php @@ -74,6 +74,31 @@ public function testLogRecordChannel() $transport->reset(); } + public function testLogRecordChannelWithSpace() + { + $level = Level::Info; + $message = 'Hello, world! ' . $level->value; + $context = ['foo' => 'bar', 'level' => $level->value]; + + $transport = $this->createDummyTransport(); + + $includeChannel = true; + $channel = "Test Channel"; + $handler = $this->createDummyHandler($transport, $level, $includeChannel); + $record = $this->getRecord($level, $message, context: $context, channel: $channel); + $handler->handle($record); + + $logEntries = $transport->getEntries(); + + $firstLogEntry = $logEntries[0]; + $this->assertEquals(1, count($logEntries)); + $this->assertEquals($firstLogEntry->getLevel(), strtoupper($record->level->name)); + $this->assertEquals($firstLogEntry->getMessage(), $record->message . " #test-channel"); + + // Reset every call + $transport->reset(); + } + private function createDummyHandler($transport, Level $level = null, $includeChannel = false) { return $this->createHandler($this->appName, $this->environmentName, $transport, $level, $includeChannel); } @@ -82,7 +107,7 @@ private function createHandler($appName, $environmentName, $transport, Level $le { $config = []; if ($includeChannel) { - $config['includeChannel'] = true; + $config['IncludeChannel'] = true; } if (null === $level) { From fcff3108e80327e683c1099e5967e78106c0f42b Mon Sep 17 00:00:00 2001 From: Michael Mantos Date: Thu, 21 Dec 2023 18:22:46 +0800 Subject: [PATCH 20/24] RTRACE-45: Include extra in context setting and test --- README.md | 26 ++++++++++ src/Stackify/Log/Monolog/Handler.php | 12 ++++- src/Stackify/Log/Monolog/LogEntry.php | 21 +++++++- tests/HandlerTest.php | 69 +++++++++++++++++++++++++-- 4 files changed, 122 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 05d3275..4f4c1c8 100644 --- a/README.md +++ b/README.md @@ -186,6 +186,32 @@ $logger = new Logger('logger'); $logger->pushHandler($handler); ``` +- **Include Extra In Context** + - This will include the extra property to the context (merging extra to context) + + ```php +use Monolog\Logger; +use Stackify\Log\Monolog\Handler as StackifyHandler; + +$transport = new ExecTransport($apiKey); // Your selected transport (Can be null which defaults to AgentSocketTransport) +$logServerVariables = false; // Default +$config = array( + 'IncludeExtraInContext' => true, + ... +); + +$handler = new StackifyHandler('application_name', 'environment_name', $transport, $logServerVariables, $config); +$logger = new Logger('logger'); +$logger->pushProcessor(function ($record) { + if (empty($record['extra'])) { + $record['extra'] = []; + } + $record['extra']['dummy'] = 1; + return $record; +}); +$logger->pushHandler($handler); +``` + ### Symfony ```yml services: diff --git a/src/Stackify/Log/Monolog/Handler.php b/src/Stackify/Log/Monolog/Handler.php index ad37dc8..707cefc 100644 --- a/src/Stackify/Log/Monolog/Handler.php +++ b/src/Stackify/Log/Monolog/Handler.php @@ -25,6 +25,11 @@ class Handler extends AbstractProcessingHandler */ private bool $includeChannel; + /** + * Include extra in context + */ + private bool $includeExtraInContext; + /** * Stackify monolog handler * @@ -62,10 +67,15 @@ public function __construct( $transport->setMessageBuilder($messageBuilder); $this->_transport = $transport; $this->includeChannel = false; + $this->includeExtraInContext = false; if ($config && array_key_exists('IncludeChannel', $config) && $config['IncludeChannel']) { $this->includeChannel = true; } + + if ($config && array_key_exists('IncludeExtraInContext', $config) && $config['IncludeExtraInContext']) { + $this->includeExtraInContext = true; + } } /** @@ -77,7 +87,7 @@ public function __construct( */ public function write(LogRecord $record): void { - $this->_transport->addEntry(new LogEntry($record, $this->includeChannel)); + $this->_transport->addEntry(new LogEntry($record, $this->includeChannel, $this->includeExtraInContext)); } /** diff --git a/src/Stackify/Log/Monolog/LogEntry.php b/src/Stackify/Log/Monolog/LogEntry.php index ad25b8d..ac36f4c 100644 --- a/src/Stackify/Log/Monolog/LogEntry.php +++ b/src/Stackify/Log/Monolog/LogEntry.php @@ -13,13 +13,16 @@ final class LogEntry implements LogEntryInterface private $record; private $exception; - private $context; + private $context = []; private $nativeError; private $includeChannel; + private $includeExtraInContext; private $channel; private static $kebabCache = []; + private $extra = []; + private $hasExtra = false; - public function __construct(MonologLogRecord $record, bool $includeChannel = false) + public function __construct(MonologLogRecord $record, bool $includeChannel = false, bool $includeExtraInContext = false) { $this->record = $record; @@ -46,19 +49,33 @@ public function __construct(MonologLogRecord $record, bool $includeChannel = fal $context['line'] ); } + if (!empty($context)) { $this->context = $context; } $this->includeChannel = $includeChannel; + $this->includeExtraInContext = $includeExtraInContext; $this->channel = null; + $this->extra = []; + $this->hasExtra = false; + if ($record && $record['channel']) { $this->channel = $record['channel']; } + + if ($record && $record['extra'] && !empty($record['extra'])) { + $this->extra = $record['extra']; + $this->hasExtra = true; + } } public function getContext() { + if ($this->includeExtraInContext && $this->hasExtra) { + return array_merge($this->context, $this->extra); + } + return $this->context; } diff --git a/tests/HandlerTest.php b/tests/HandlerTest.php index 06a0e63..36c80dc 100644 --- a/tests/HandlerTest.php +++ b/tests/HandlerTest.php @@ -99,17 +99,80 @@ public function testLogRecordChannelWithSpace() $transport->reset(); } - private function createDummyHandler($transport, Level $level = null, $includeChannel = false) { - return $this->createHandler($this->appName, $this->environmentName, $transport, $level, $includeChannel); + + public function testLogRecordWithExtra() + { + $level = Level::Info; + $message = 'Hello, world! ' . $level->value; + $context = ['foo' => 'bar', 'level' => $level->value]; + $extra = ['extra' => 'bar']; + $mergedContext = array_merge($context, $extra); + + $transport = $this->createDummyTransport(); + + $includeChannel = true; + $includeExtra = true; + $channel = "test"; + $handler = $this->createDummyHandler($transport, $level, $includeChannel, $includeExtra); + $record = $this->getRecord($level, $message, context: $context, channel: $channel, extra: $extra); + $handler->handle($record); + + $logEntries = $transport->getEntries(); + + $firstLogEntry = $logEntries[0]; + $this->assertEquals(1, count($logEntries)); + $this->assertEquals($firstLogEntry->getLevel(), strtoupper($record->level->name)); + $this->assertEquals($firstLogEntry->getMessage(), $record->message . " #{$channel}"); + $this->assertSame($firstLogEntry->getContext(), $mergedContext); + + // Reset every call + $transport->reset(); } - private function createHandler($appName, $environmentName, $transport, Level $level = null, bool $includeChannel = false): Handler + public function testLogRecordWithExtraButDisabledSetting() + { + $level = Level::Info; + $message = 'Hello, world! ' . $level->value; + $context = ['foo' => 'bar', 'level' => $level->value]; + $extra = ['extra' => 'bar']; + $mergedContext = array_merge($context, $extra); + + $transport = $this->createDummyTransport(); + + $includeChannel = true; + $includeExtra = false; + $channel = "test"; + $handler = $this->createDummyHandler($transport, $level, $includeChannel, $includeExtra); + $record = $this->getRecord($level, $message, context: $context, channel: $channel, extra: $extra); + $handler->handle($record); + + $logEntries = $transport->getEntries(); + + $firstLogEntry = $logEntries[0]; + $this->assertEquals(1, count($logEntries)); + $this->assertEquals($firstLogEntry->getLevel(), strtoupper($record->level->name)); + $this->assertEquals($firstLogEntry->getMessage(), $record->message . " #{$channel}"); + $this->assertNotSame($firstLogEntry->getContext(), $mergedContext); + + // Reset every call + $transport->reset(); + } + + private function createDummyHandler($transport, Level $level = null, $includeChannel = false, $includeExtra = false) { + return $this->createHandler($this->appName, $this->environmentName, $transport, $level, $includeChannel, $includeExtra); + } + + private function createHandler($appName, $environmentName, $transport, Level $level = null, bool $includeChannel = false, bool $includeExtra = false): Handler { $config = []; if ($includeChannel) { $config['IncludeChannel'] = true; } + if ($includeExtra) { + $config['IncludeExtraInContext'] = true; + } + if (null === $level) { $handler = new Handler($appName, $environmentName, $transport, false, $config, $level); } else { From 89486e787b2e8e87d9683003d6c662bd67af03e9 Mon Sep 17 00:00:00 2001 From: Michael Mantos Date: Fri, 22 Dec 2023 23:28:32 +0800 Subject: [PATCH 21/24] RTRACE-45: Autoload dev fix --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index e19f00c..668021e 100644 --- a/composer.json +++ b/composer.json @@ -19,11 +19,11 @@ "autoload": { "psr-4": { "Stackify\\Log\\Monolog\\": "src/Stackify/Log/Monolog" - }, - "autoload-dev": { - "psr-4": {"Stackify\\Log\\Monolog\\Tests": "tests/"} } }, + "autoload-dev": { + "psr-4": {"Stackify\\Log\\Monolog\\Tests": "tests/"} + }, "minimum-stability": "dev", "prefer-stable": true } From 6021daa043f9a41b74d5697b914b4565262ef21b Mon Sep 17 00:00:00 2001 From: Michael Mantos Date: Wed, 17 Jan 2024 15:30:04 +0800 Subject: [PATCH 22/24] Fix autoload dev PSR-4 issue --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 668021e..b44e2cd 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ } }, "autoload-dev": { - "psr-4": {"Stackify\\Log\\Monolog\\Tests": "tests/"} + "psr-4": {"Stackify\\Log\\Monolog\\Tests\\": "tests/"} }, "minimum-stability": "dev", "prefer-stable": true From 555b9ba3114931233b329f97ed83922206099b26 Mon Sep 17 00:00:00 2001 From: Michael Mantos Date: Thu, 9 May 2024 21:50:19 +0800 Subject: [PATCH 23/24] PHP-84 - Update php logger dependency to include 2.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b44e2cd..979fcfd 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "license": "Apache-2.0", "require": { "php": ">=8.1", - "stackify/logger": "~1.6", + "stackify/logger": "~1.6 || ~2.0", "monolog/monolog": "~3.0" }, "require-dev": { From f5ad53e7799b034925985a1bbacdcfa84184739b Mon Sep 17 00:00:00 2001 From: Todd Lair Date: Mon, 3 Nov 2025 14:18:47 -0600 Subject: [PATCH 24/24] Removing Veracode scanning --- azure-pipelines.yml | 56 ++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 4be7f02..0928e04 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -32,31 +32,31 @@ steps: - script: composer install --no-interaction --prefer-dist displayName: 'composer install' -- task: CmdLine@2 - inputs: - script: 'curl -sSL https://www.sourceclear.com/install | bash' -- task: CmdLine@2 - inputs: - script: 'srcclr scan .' - env: - SRCCLR_API_TOKEN: $(SRCCLR_API_TOKEN) -- task: CmdLine@2 - displayName: 'Make Directory' - inputs: - script: 'mkdir temp' -- task: CmdLine@2 - displayName: 'Copy Files' - inputs: - script: 'cp src/Stackify/Log/Monolog/Handler.php temp && cp src/Stackify/Log/Monolog/LogEntry.php temp && cp composer.json temp' -- task: CmdLine@2 - displayName: 'Make zip' - inputs: - script: 'zip -r stackify-log-monolog.zip temp' -- task: Veracode@3 - inputs: - ConnectionDetailsSelection: 'Endpoint' - AnalysisService: 'Veracode' - veracodeAppProfile: 'Retrace PHP Monolog library' - version: 'AZ-Devops-Build-$(build.buildNumber)' - filepath: 'stackify-log-monolog.zip' - maximumWaitTime: '360' \ No newline at end of file +#- task: CmdLine@2 +# inputs: +# script: 'curl -sSL https://www.sourceclear.com/install | bash' +#- task: CmdLine@2 +# inputs: +# script: 'srcclr scan .' +# env: +# SRCCLR_API_TOKEN: $(SRCCLR_API_TOKEN) +#- task: CmdLine@2 +# displayName: 'Make Directory' +# inputs: +# script: 'mkdir temp' +#- task: CmdLine@2 +# displayName: 'Copy Files' +# inputs: +# script: 'cp src/Stackify/Log/Monolog/Handler.php temp && cp src/Stackify/Log/Monolog/LogEntry.php temp && cp composer.json temp' +#- task: CmdLine@2 +# displayName: 'Make zip' +# inputs: +# script: 'zip -r stackify-log-monolog.zip temp' +#- task: Veracode@3 +# inputs: +# ConnectionDetailsSelection: 'Endpoint' +# AnalysisService: 'Veracode' +# veracodeAppProfile: 'Retrace PHP Monolog library' +# version: 'AZ-Devops-Build-$(build.buildNumber)' +# filepath: 'stackify-log-monolog.zip' +# maximumWaitTime: '360' \ No newline at end of file