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
Commits
2a9bc986
Commit
2a9bc986
authored
6 years ago
by
Dyszczo
Browse files
Options
Downloads
Plain Diff
Merge branch 'bugfix/tests' into 'master'
tests fix + custom file See merge request
!10
parents
3989dae4
f82d7f5d
No related branches found
No related tags found
1 merge request
!10
tests fix + custom file
Pipeline
#6536
failed
6 years ago
Stage: tools
Stage: tests
Stage: pre-deploy
Stage: deploy
Changes
3
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+6
-0
6 additions, 0 deletions
CHANGELOG.md
src/WP/WPCapture.php
+4
-2
4 additions, 2 deletions
src/WP/WPCapture.php
src/WPDeskLoggerFactory.php
+26
-11
26 additions, 11 deletions
src/WPDeskLoggerFactory.php
with
36 additions
and
13 deletions
CHANGELOG.md
+
6
−
0
View file @
2a9bc986
## [1.5.1] - 2019-04-23
### Changed
-
Two files for custom loggers (default+custom)
### Fixed
-
Tests
## [1.5.0] - 2019-04-18
### Changed
-
Log file is unified with old way logger and all is logged in /wp-content/uploads/wpdesk-logs/wpdesk_debug.log
...
...
This diff is collapsed.
Click to expand it.
src/WP/WPCapture.php
+
4
−
2
View file @
2a9bc986
...
...
@@ -6,6 +6,8 @@ class WPCapture {
/** @var string */
private
$filename
;
const
LOG_DIR
=
'wpdesk-logs'
;
public
function
__construct
(
$filename
)
{
$this
->
filename
=
$filename
;
}
...
...
@@ -115,7 +117,7 @@ class WPCapture {
* @return string
*/
private
function
get_log_dir
()
{
return
trailingslashit
(
$this
->
get_uploads_dir
()
)
.
'wpdesk-logs'
;
return
trailingslashit
(
$this
->
get_uploads_dir
()
)
.
self
::
LOG_DIR
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
src/WPDeskLoggerFactory.php
+
26
−
11
View file @
2a9bc986
...
...
@@ -84,30 +84,44 @@ class WPDeskLoggerFactory extends BasicLoggerFactory
return
Registry
::
getInstance
(
$name
);
}
$logger
=
$this
->
createLogger
(
$name
);
$wpCapture
=
$this
->
captureWPLog
(
$name
);
$this
->
captureWooCommerce
(
$logger
);
$this
->
appendMainLog
(
$logger
);
if
(
$name
!==
self
::
DEFAULT_LOGGER_CHANNEL_NAME
)
{
$this
->
appendFileLog
(
$logger
,
$this
->
getFileName
(
$name
));
}
return
$logger
;
}
/**
* @param $logger
*/
private
function
appendMainLog
(
$logger
)
{
$wpCapture
=
$this
->
captureWPLog
();
$this
->
appendFileLog
(
$logger
,
$wpCapture
->
get_log_file
());
}
/**
* @param Logger $logger
*/
private
function
appendFileLog
(
$logger
,
$filename
)
{
try
{
$this
->
pushFileHandle
(
$
wpCapture
->
get_log_file
()
,
$logger
);
$this
->
pushFileHandle
(
$
filename
,
$logger
);
}
catch
(
InvalidArgumentException
$e
)
{
$logger
->
emergency
(
'
File log
could not be created - invalid filename.'
);
$logger
->
emergency
(
'
Main log file
could not be created - invalid filename.'
);
}
catch
(
Exception
$e
)
{
$logger
->
emergency
(
'
File log
could not be written.'
);
$logger
->
emergency
(
'
Main log file
could not be written.'
);
}
return
$logger
;
}
/**
* @param $name
*
* @return WPCapture
*/
private
function
captureWPLog
(
$name
)
{
private
function
captureWPLog
()
{
static
$wpCapture
;
if
(
!
$wpCapture
)
{
$wpCapture
=
new
WPCapture
(
$this
->
getFileName
(
$name
));
$wpCapture
=
new
WPCapture
(
basename
(
$this
->
getFileName
(
)
));
$wpCapture
->
init_debug_log_file
();
}
...
...
@@ -162,7 +176,8 @@ class WPDeskLoggerFactory extends BasicLoggerFactory
*/
public
function
getFileName
(
$name
=
self
::
DEFAULT_LOGGER_CHANNEL_NAME
)
{
return
$name
.
'_debug.log'
;
$upload_dir
=
wp_upload_dir
();
return
trailingslashit
(
untrailingslashit
(
$upload_dir
[
'basedir'
]
)
)
.
WPCapture
::
LOG_DIR
.
DIRECTORY_SEPARATOR
.
$name
.
'_debug.log'
;
}
/**
...
...
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