@@ -170,33 +170,94 @@ use TinyBlocks\Logger\Redactions\PhoneRedaction;
170170PhoneRedaction::from(fields: ['phone', 'mobile', 'whatsapp'], visibleSuffixLength: 4);
171171```
172172
173+ #### Password redaction
174+
175+ Masks the entire value. No characters are preserved.
176+
177+ ``` php
178+ use TinyBlocks\Logger\StructuredLogger;
179+ use TinyBlocks\Logger\Redactions\PasswordRedaction;
180+
181+ $logger = StructuredLogger::create()
182+ ->withComponent(component: 'auth-service')
183+ ->withRedactions(PasswordRedaction::default())
184+ ->build();
185+
186+ $logger->info(message: 'login.attempt', context: ['password' => 's3cr3t!']);
187+ # password → "*******"
188+ ```
189+
190+ With custom fields:
191+
192+ ``` php
193+ use TinyBlocks\Logger\Redactions\PasswordRedaction;
194+
195+ PasswordRedaction::from(fields: ['password', 'secret', 'token']);
196+ ```
197+
198+ #### Name redaction
199+
200+ Preserves the first N characters (default: 2) and masks the rest.
201+
202+ ``` php
203+ use TinyBlocks\Logger\StructuredLogger;
204+ use TinyBlocks\Logger\Redactions\NameRedaction;
205+
206+ $logger = StructuredLogger::create()
207+ ->withComponent(component: 'user-service')
208+ ->withRedactions(NameRedaction::default())
209+ ->build();
210+
211+ $logger->info(message: 'user.created', context: ['name' => 'Gustavo']);
212+ # name → "Gu*****"
213+ ```
214+
215+ With custom fields and visible length:
216+
217+ ``` php
218+ use TinyBlocks\Logger\Redactions\NameRedaction;
219+
220+ NameRedaction::from(fields: ['name', 'full_name', 'firstName'], visiblePrefixLength: 3);
221+ # "Gustavo" → "Gus****"
222+ # "Gustavo Freze" → "Gus**********"
223+ # "Maria" → "Mar**"
224+ ```
225+
173226#### Composing multiple redactions
174227
175228``` php
176229use TinyBlocks\Logger\StructuredLogger;
177230use TinyBlocks\Logger\Redactions\DocumentRedaction;
178231use TinyBlocks\Logger\Redactions\EmailRedaction;
232+ use TinyBlocks\Logger\Redactions\NameRedaction;
233+ use TinyBlocks\Logger\Redactions\PasswordRedaction;
179234use TinyBlocks\Logger\Redactions\PhoneRedaction;
180235
181236$logger = StructuredLogger::create()
182237 ->withComponent(component: 'user-service')
183238 ->withRedactions(
184239 DocumentRedaction::default(),
185240 EmailRedaction::default(),
186- PhoneRedaction::default()
241+ PhoneRedaction::default(),
242+ PasswordRedaction::default(),
243+ NameRedaction::default()
187244 )
188245 ->build();
189246
190247$logger->info(message: 'user.registered', context: [
191248 'document' => '12345678900',
192249 'email' => 'john@example.com',
193250 'phone' => '+5511999887766',
194- 'name' => 'John'
251+ 'password' => 's3cr3t!',
252+ 'name' => 'John',
253+ 'status' => 'active'
195254]);
196255# document → "********900"
197256# email → "jo**@example.com"
198257# phone → "**********7766"
199- # name → "John" (unchanged)
258+ # password → "*******"
259+ # name → "Jo**"
260+ # status → "active" (unchanged)
200261```
201262
202263#### Custom redaction
@@ -274,4 +335,4 @@ Logger is licensed under [MIT](LICENSE).
274335## Contributing
275336
276337Please follow the [ contributing guidelines] ( https://github.com/tiny-blocks/tiny-blocks/blob/main/CONTRIBUTING.md ) to
277- contribute to the project.
338+ contribute to the project.
0 commit comments