Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow logging to multiple sinks #689

Merged
merged 1 commit into from
Oct 29, 2024

Conversation

tienvx
Copy link
Contributor

@tienvx tienvx commented Oct 28, 2024

  • Allow logging to multiple sinks: file, buffer, stdout, stderr

    • Usage

      $logger = Logger::instance();
      $logger->attach(new File('/path/to/file', LogLevel::DEBUG));
      $logger->attach(new Buffer(LogLevel::ERROR));
      $logger->attach(new Stdout(LogLevel::WARN));
      $logger->attach(new Stderr(LogLevel::INFO));
      $logger->apply();
  • Add PHPUnit logging extension

    • It define sinks base on values of PACT_LOGLEVEL and PACT_LOG then apply logger. These environment variables are already defined from v9 but only PACT_LOGLEVEL is used in v10

    • Implements [Feature Enhancement] - v10.x - Support logging to file #341

    • Usage

      <?xml version="1.0" encoding="UTF-8"?>
      <phpunit bootstrap="./autoload.php" colors="true">
          <testsuites>
              <testsuite name="PhpPact Example Tests">
                  <directory>./tests</directory>
              </testsuite>
          </testsuites>
          <php>
              <env name="PACT_LOG" value="./log/pact.txt"/>
              <env name="PACT_LOGLEVEL" value="DEBUG"/>
          </php>
          <extensions>
              <bootstrap class="PhpPact\Log\PHPUnit\PactLoggingExtension"/>
          </extensions>
      </phpunit>
      

@coveralls
Copy link

coveralls commented Oct 28, 2024

Pull Request Test Coverage Report for Build 11562310140

Details

  • 110 of 117 (94.02%) changed or added relevant lines in 11 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.1%) to 96.3%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/PhpPact/Log/Logger.php 37 39 94.87%
src/PhpPact/Log/PHPUnit/PactLoggingExtension.php 0 2 0.0%
src/PhpPact/FFI/Client.php 29 32 90.63%
Totals Coverage Status
Change from base Build 11432984490: -0.1%
Covered Lines: 2577
Relevant Lines: 2676

💛 - Coveralls

@tienvx tienvx force-pushed the add-phpunit-logging-extension branch from aa39504 to bf5fe73 Compare October 28, 2024 20:42
@tienvx tienvx requested review from JP-Ellis and YOU54F October 29, 2024 00:17
@tienvx tienvx merged commit 0e38dd2 into pact-foundation:master Oct 29, 2024
18 checks passed
@tienvx tienvx deleted the add-phpunit-logging-extension branch October 29, 2024 00:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants