Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
wp-logs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wpdesk
wp-logs
Merge requests
!27
feature(processor): sensitive data processor
Code
Review changes
Check out branch
Download
Patches
Plain diff
Expand sidebar
Merged
feature(processor): sensitive data processor
feature/sensitive-data
into
master
Overview
0
Commits
1
Pipelines
1
Changes
5
Merged
Grzegorz Rola
requested to merge
feature/sensitive-data
into
master
1 year ago
Overview
0
Commits
1
Pipelines
1
Changes
5
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
611464c6
1 commit,
1 year ago
5 files
+
131
−
4
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
5
src/Processor/SensitiveDataProcessor.php
0 → 100644
+
51
−
0
View file @ 611464c6
Edit in single-file editor
Open in Web IDE
<?php
namespace
WPDesk\Logger\Processor
;
use
Monolog\Processor\ProcessorInterface
;
/**
* Can replace data in log.
* Ie. sensitive data.
*
* @package WPDesk\Logger\Processor
*/
class
SensitiveDataProcessor
implements
ProcessorInterface
{
/**
* Replace array.
*
* @var array
*/
private
array
$replace
;
public
function
__construct
(
array
$replace
)
{
$this
->
replace
=
$replace
;
}
public
function
__invoke
(
array
$record
):
array
{
return
$this
->
replace_array
(
$record
);
}
private
function
replace_array
(
array
$value
):
array
{
foreach
(
$value
as
$key
=>
$item
)
{
if
(
is_array
(
$item
)
)
{
$value
[
$key
]
=
$this
->
replace_array
(
$item
);
}
if
(
is_string
(
$item
)
)
{
$value
[
$key
]
=
$this
->
replace
(
$item
);
}
}
return
$value
;
}
private
function
replace
(
string
$value
):
string
{
foreach
(
$this
->
replace
as
$search
=>
$replace
)
{
$value
=
str_replace
(
$search
,
$replace
,
$value
);
}
return
$value
;
}
}
Loading