Skip to content

Commit

Permalink
Ability to disable tap loader (#37)
Browse files Browse the repository at this point in the history
* Removes duplicate section in README file.
* Updates the README file to provide instructions on how to disable the tap loader using the scrubber configuration file.
* Removes the default auto-loading of all tap channels.
* Updates the TapLoaderStrategy handlers to check the value of Config::get('scrubber.tap_channels') and disable the loading of any taps if it is set to false.
* Improves the test coverage to ensure comprehensive testing of the updated functionality.
* Updates configuration file to ship with tap loader opt out by default.
  • Loading branch information
yordadev authored Jun 23, 2023
1 parent f101d84 commit fb51702
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 92 deletions.
20 changes: 5 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,6 @@ Scrubber::processMessage([
Scrubber::processMessage('<insert jwt token here>');
// **redacted**
```
## Log Channel Opt-in

This package provides you the ability to define through the configuration file what channels you want to scrub
specifically. By default, this package ships with a wildcard value and opts in to scrub all the log channels
in your application.

### Defining Log Channel Opt-in
To opt in to one or more channels, list the channel(s) name into the `tap_channels` array in the config.

```php
'tap_channels' => [
'single',
'papertrail'
]
```

## Log Channel Opt-in

Expand All @@ -136,6 +121,11 @@ To opt in to one or more channels, list the channel(s) name into the `tap_channe
]
```

To disable tap logging functionality and use the package independently and not tap your Laravel application logging, modify the config file by setting the tap_channels field as follows:
```php
'tap_channels' => false
```

## Regex Class Opt-in

You have the ability through the configuration file to define what regex classes you want loaded into the application
Expand Down
78 changes: 39 additions & 39 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion config/scrubber.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
],
],
'regex_loader' => ['*'],
'tap_channels' => ['*'],
'tap_channels' => false,
];
2 changes: 0 additions & 2 deletions src/ScrubberServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use YorCreative\Scrubber\Strategies\RegexLoader\Loaders\SpecificExtendedRegex;
use YorCreative\Scrubber\Strategies\RegexLoader\Loaders\WildcardExtendedRegex;
use YorCreative\Scrubber\Strategies\RegexLoader\RegexLoaderStrategy;
use YorCreative\Scrubber\Strategies\TapLoader\Loaders\DefaultChannels;
use YorCreative\Scrubber\Strategies\TapLoader\Loaders\MultipleChannel;
use YorCreative\Scrubber\Strategies\TapLoader\Loaders\SpecificChannel;
use YorCreative\Scrubber\Strategies\TapLoader\Loaders\WildCardChannel;
Expand Down Expand Up @@ -71,7 +70,6 @@ public function boot()
$tapLoaderStrategy->setLoader(new WildCardChannel());
$tapLoaderStrategy->setLoader(new SpecificChannel());
$tapLoaderStrategy->setLoader(new MultipleChannel());
$tapLoaderStrategy->setLoader(new DefaultChannels());

return $tapLoaderStrategy;
});
Expand Down
25 changes: 0 additions & 25 deletions src/Strategies/TapLoader/Loaders/DefaultChannels.php

This file was deleted.

3 changes: 2 additions & 1 deletion src/Strategies/TapLoader/Loaders/MultipleChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ class MultipleChannel implements TapLoaderInterface
public function canLoad(): bool
{
$channels = Config::get('scrubber.tap_channels');
if (! $channels) {

if (! $channels || ! is_array($channels)) {
return false;
}

Expand Down
3 changes: 2 additions & 1 deletion src/Strategies/TapLoader/Loaders/SpecificChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ class SpecificChannel implements TapLoaderInterface
public function canLoad(): bool
{
$channels = Config::get('scrubber.tap_channels');
if (! $channels) {

if (! $channels || ! is_array($channels)) {
return false;
}

Expand Down
3 changes: 2 additions & 1 deletion src/Strategies/TapLoader/Loaders/WildCardChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ class WildCardChannel implements TapLoaderInterface
public function canLoad(): bool
{
$channels = Config::get('scrubber.tap_channels');
if (! $channels) {

if (! $channels || ! is_array($channels)) {
return false;
}

Expand Down
Loading

0 comments on commit fb51702

Please sign in to comment.