Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
wp-logs
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wpdesk
wp-logs
Commits
4bf2e587
Verified
Commit
4bf2e587
authored
3 years ago
by
Bartek Jaskulski
Browse files
Options
Downloads
Plain Diff
Merge branch 'bugfix/default-channel'
parents
68bc278c
fd35bbc9
No related branches found
No related tags found
1 merge request
!19
Bugfix/default channel
Pipeline
#7696
failed with stages
in 2 minutes and 53 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+2
-2
2 additions, 2 deletions
CHANGELOG.md
src/SimpleLoggerFactory.php
+1
-1
1 addition, 1 deletion
src/SimpleLoggerFactory.php
src/WC/WooCommerceHandler.php
+29
-22
29 additions, 22 deletions
src/WC/WooCommerceHandler.php
with
32 additions
and
25 deletions
CHANGELOG.md
+
2
−
2
View file @
4bf2e587
## [Unreleased]
## [Unreleased]
### Fixed
### Fixed
-
Fixed no handler actually assigned when using combination of
-
Fixed no handler actually assigned when using combination of
NullHandler and actual one
NullHandler and actual o
ne
-
WooCommerce channel is now taken from logger registered chan
ne
l
## [1.7.1] - 2022-04-15
## [1.7.1] - 2022-04-15
### Fixed
### Fixed
...
...
This diff is collapsed.
Click to expand it.
src/SimpleLoggerFactory.php
+
1
−
1
View file @
4bf2e587
...
@@ -36,7 +36,7 @@ final class SimpleLoggerFactory implements LoggerFactory {
...
@@ -36,7 +36,7 @@ final class SimpleLoggerFactory implements LoggerFactory {
$logger
->
pushHandler
(
$logger
->
pushHandler
(
new
WooCommerceHandler
(
new
WooCommerceHandler
(
\wc_get_logger
(),
\wc_get_logger
(),
$this
->
options
->
lev
el
s
$this
->
chann
el
)
)
);
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/WC/WooCommerceHandler.php
+
29
−
22
View file @
4bf2e587
...
@@ -9,36 +9,43 @@ use Monolog\Logger;
...
@@ -9,36 +9,43 @@ use Monolog\Logger;
* Class WooCommerceFactory
* Class WooCommerceFactory
*/
*/
class
WooCommerceHandler
extends
AbstractProcessingHandler
{
class
WooCommerceHandler
extends
AbstractProcessingHandler
{
const
DEFAULT_WC_SOURCE
=
'wpdesk-logger'
;
const
DEFAULT_WC_SOURCE
=
'wpdesk-logger'
;
/** @var \WC_Logger_Interface */
/** @var \WC_Logger_Interface */
private
$wc_logger
;
private
$wc_logger
;
/**
/** @var string */
* Writes the record down to the log of the implementing handler
private
$channel
;
*
* @param array $record
/**
* @return void
* Writes the record down to the log of the implementing handler
*/
*
protected
function
write
(
array
$record
)
* @param array $record
{
* @return void
$context
=
array_merge
([
*/
'source'
=>
self
::
DEFAULT_WC_SOURCE
protected
function
write
(
array
$record
)
{
],
$record
[
'extra'
],
$record
[
'context'
]);
$context
=
array_merge
(
[
$this
->
wc_logger
->
log
(
$this
->
convertMonologLevelToWC
(
$record
[
'level'
]),
$record
[
'message'
],
$context
);
'source'
=>
$this
->
channel
;,
],
$record
[
'extra'
],
$record
[
'context'
]
);
$this
->
wc_logger
->
log
(
$this
->
convertMonologLevelToWC
(
$record
[
'level'
]
),
$record
[
'message'
],
$context
);
}
}
/**
/**
* @param int $level
* @param int $level
* @return string
* @return string
*/
*/
private
function
convertMonologLevelToWC
(
$level
)
{
private
function
convertMonologLevelToWC
(
$level
)
{
return
Logger
::
getLevelName
(
$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
();
parent
::
__construct
();
$this
->
wc_logger
=
$originalWcLogger
;
$this
->
wc_logger
=
$originalWcLogger
;
$this
->
channel
=
$channel
;
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment