Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
die_coolen_jungs
our_own_cloud_project
Commits
8c69a538
Commit
8c69a538
authored
11 years ago
by
Thomas Müller
Browse files
Options
Downloads
Plain Diff
Merge pull request #5478 from owncloud/core-logexceptionstacktrace
Expand exception stack trace in log in debug mode
parents
959b0f91
c4dee281
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
index.php
+2
-1
2 additions, 1 deletion
index.php
lib/public/util.php
+33
-0
33 additions, 0 deletions
lib/public/util.php
with
35 additions
and
1 deletion
index.php
+
2
−
1
View file @
8c69a538
...
...
@@ -30,8 +30,9 @@ try {
OC
::
handleRequest
();
}
catch
(
Exception
$ex
)
{
\OCP\Util
::
logException
(
'index'
,
$ex
);
//show the user a detailed error page
\OCP\Util
::
writeLog
(
'index'
,
$ex
->
getMessage
(),
\OCP\Util
::
FATAL
);
OC_Response
::
setStatus
(
OC_Response
::
STATUS_INTERNAL_SERVER_ERROR
);
OC_Template
::
printExceptionErrorPage
(
$ex
);
}
This diff is collapsed.
Click to expand it.
lib/public/util.php
+
33
−
0
View file @
8c69a538
...
...
@@ -77,6 +77,39 @@ class Util {
\OC_LOG
::
write
(
$app
,
$message
,
$level
);
}
/**
* @brief write exception into the log. Include the stack trace
* if DEBUG mode is enabled
* @param Exception $ex exception to log
*/
public
static
function
logException
(
$app
,
\Exception
$ex
)
{
$message
=
$ex
->
getMessage
();
if
(
$ex
->
getCode
())
{
$message
.
=
' ['
.
$ex
->
getCode
()
.
']'
;
}
\OCP\Util
::
writeLog
(
$app
,
'Exception: '
.
$message
,
\OCP\Util
::
FATAL
);
if
(
defined
(
'DEBUG'
)
and
DEBUG
)
{
// also log stack trace
$stack
=
explode
(
'#'
,
$ex
->
getTraceAsString
());
// first element is empty
array_shift
(
$stack
);
foreach
(
$stack
as
$s
)
{
\OCP\Util
::
writeLog
(
$app
,
'Exception: '
.
$s
,
\OCP\Util
::
FATAL
);
}
// include cause
$l
=
\OC_L10N
::
get
(
'lib'
);
while
(
method_exists
(
$ex
,
'getPrevious'
)
&&
$ex
=
$ex
->
getPrevious
())
{
$message
.
=
' - '
.
$l
->
t
(
'Caused by:'
)
.
' '
;
$message
.
=
$ex
->
getMessage
();
if
(
$ex
->
getCode
())
{
$message
.
=
'['
.
$ex
->
getCode
()
.
'] '
;
}
\OCP\Util
::
writeLog
(
$app
,
'Exception: '
.
$message
,
\OCP\Util
::
FATAL
);
}
}
}
/**
* @brief get l10n object
* @param string $app
...
...
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