Skip to content

Conversation

lukinovec
Copy link
Contributor

@lukinovec lukinovec commented Jul 28, 2025

This PR adds the LogTenancyBootstrapper to provide tenant-specific logging configuration. The bootstrapper automatically configures storage path channels to use tenant-specific directories (NOTE: for this to work correctly, the bootstrapper has to run AFTER FilesystemTenancyBootstrapper, otherwise, the logs still won't be separated) and supports custom channel overrides for custom logging scenarios (e.g. the slack channel, see the bootstrapper's comments).

Note that the bootstrapper first modifies the channel config, then forgets the channel so that on the next logging attempt, the channel is re-resolved with the modified config. Otherwise, the channel would just use the initial config (in most cases). When using a channel stack, the stack channel itself also has to be forgotten, since the LogManager could retain e.g. the original stack channel's webhook URL, while the underlying slack channel would use the updated one, and while logging, the app would actually use the initial webhook URL instead of the updated one -- encountered this very specific issue while testing).

Also, note: adding 'attachment' => 'false' to the slack channel's config makes the slack channel work with Discord webhooks (just a cool thing we figured out whlle testing the bootstrapper).

Copy link

codecov bot commented Jul 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.28%. Comparing base (3b42c9e) to head (412c1d0).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1381      +/-   ##
============================================
+ Coverage     86.14%   86.28%   +0.14%     
- Complexity     1112     1128      +16     
============================================
  Files           179      180       +1     
  Lines          3254     3288      +34     
============================================
+ Hits           2803     2837      +34     
  Misses          451      451              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lukinovec lukinovec requested a review from Copilot July 29, 2025 11:28
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new LogTenancyBootstrapper to provide tenant-specific logging configuration. The bootstrapper automatically configures storage path channels to use tenant-specific directories and supports custom channel overrides for more complex logging scenarios.

Key changes:

  • Implements LogTenancyBootstrapper with automatic storage path channel configuration and custom override support
  • Adds comprehensive test coverage for default behavior, custom overrides, and real-world usage scenarios
  • Registers the new bootstrapper in the test environment

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/Bootstrappers/LogTenancyBootstrapper.php Main implementation of the log tenancy bootstrapper with storage path handling and channel override functionality
tests/Bootstrappers/LogTenancyBootstrapperTest.php Comprehensive test suite covering default behavior, custom overrides, stack channels, and real logging scenarios
tests/TestCase.php Adds import and singleton registration for the new bootstrapper in test environment
Comments suppressed due to low confidence (1)

tests/Bootstrappers/LogTenancyBootstrapperTest.php:345

  • The test relies on catching exceptions to verify webhook URLs, but this approach is fragile and may not work reliably across different environments or Laravel versions. Consider mocking the HTTP client or using a more deterministic testing approach.
    try {

@lukinovec lukinovec marked this pull request as ready for review July 29, 2025 11:36
@lukinovec lukinovec requested a review from stancl July 29, 2025 11:36
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.

2 participants