Skip to content

Commit 0ad6d9e

Browse files
committed
add example of removing sensitive data in the README
1 parent 6374dbd commit 0ad6d9e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

README.md

+20
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,26 @@ Http::log($context, ['example-config-key' => 'value'])->get('https://example.com
8080
Http::logWhen($condition, $context, ['example-config-key' => 'value'])->get('https://example.com');
8181
```
8282

83+
### Removing sensitive data from logs
84+
85+
Sensitive information should be masked or replaced with placeholders before being written to log files. The configuration allows you to replace header values, query parameters, and specific strings in the response. You can also define custom, on-demand configurations to remove sensitive data.
86+
87+
For example:
88+
89+
```php
90+
Http::log([], [
91+
'replace' => ['3566002020360505' => '************0505'],
92+
'replace_headers' => ['Authorization']
93+
])
94+
->withToken('my-token')
95+
->post('https://www.example.com/verify-credit-card', ['card' => '3566002020360505']);
96+
```
97+
98+
In this case:
99+
100+
- The authorization token is completely removed from the logs.
101+
- The credit card number is partially masked, preserving only the last four digits (`************0505`).
102+
83103
### Specifying a logger
84104
The default logger and filter are specified in the package configuration `logger` and `filter` respectively but can be changed at runtime using:
85105
```php

0 commit comments

Comments
 (0)