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
!19
Bugfix/default channel
Code
Review changes
Check out branch
Download
Patches
Plain diff
Expand sidebar
Merged
Bugfix/default channel
bugfix/default-channel
into
master
Overview
0
Commits
2
Pipelines
1
Changes
3
Merged
Krzysztof Dyszczyk
requested to merge
bugfix/default-channel
into
master
3 years ago
Overview
0
Commits
2
Pipelines
1
Changes
3
@potreb
To może Cię zainteresować :)
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
fd35bbc9
2 commits,
3 years ago
3 files
+
34
−
23
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
src/WC/WooCommerceHandler.php
+
29
−
22
View file @ fd35bbc9
Edit in single-file editor
Open in Web IDE
Show full file
@@ -9,36 +9,43 @@ use Monolog\Logger;
* Class WooCommerceFactory
*/
class
WooCommerceHandler
extends
AbstractProcessingHandler
{
const
DEFAULT_WC_SOURCE
=
'wpdesk-logger'
;
const
DEFAULT_WC_SOURCE
=
'wpdesk-logger'
;
/** @var \WC_Logger_Interface */
private
$wc_logger
;
/**
* Writes the record down to the log of the implementing handler
*
* @param array $record
* @return void
*/
protected
function
write
(
array
$record
)
{
$context
=
array_merge
([
'source'
=>
self
::
DEFAULT_WC_SOURCE
],
$record
[
'extra'
],
$record
[
'context'
]);
$this
->
wc_logger
->
log
(
$this
->
convertMonologLevelToWC
(
$record
[
'level'
]),
$record
[
'message'
],
$context
);
/** @var string */
private
$channel
;
/**
* Writes the record down to the log of the implementing handler
*
* @param array $record
* @return void
*/
protected
function
write
(
array
$record
)
{
$context
=
array_merge
(
[
'source'
=>
$this
->
channel
;,
],
$record
[
'extra'
],
$record
[
'context'
]
);
$this
->
wc_logger
->
log
(
$this
->
convertMonologLevelToWC
(
$record
[
'level'
]
),
$record
[
'message'
],
$context
);
}
/**
* @param int $level
* @return string
*/
private
function
convertMonologLevelToWC
(
$level
)
{
return
Logger
::
getLevelName
(
$level
);
}
/**
* @param int $level
* @return string
*/
private
function
convertMonologLevelToWC
(
$level
)
{
return
Logger
::
getLevelName
(
$level
);
}
public
function
__construct
(
\WC_Logger_Interface
$originalWcLogger
)
{
public
function
__construct
(
\WC_Logger_Interface
$originalWcLogger
,
string
$channel
=
self
::
DEFAULT_WC_SOURCE
)
{
parent
::
__construct
();
$this
->
wc_logger
=
$originalWcLogger
;
$this
->
channel
=
$channel
;
}
}
Loading