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
4a493c88
Commit
4a493c88
authored
11 years ago
by
Vincent Petry
Browse files
Options
Downloads
Patches
Plain Diff
Some expected Sabre exceptions are now logged with DEBUG level
parent
341fcdc3
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/private/connector/sabre/exceptionloggerplugin.php
+15
-2
15 additions, 2 deletions
lib/private/connector/sabre/exceptionloggerplugin.php
lib/public/util.php
+5
-4
5 additions, 4 deletions
lib/public/util.php
with
20 additions
and
6 deletions
lib/private/connector/sabre/exceptionloggerplugin.php
+
15
−
2
View file @
4a493c88
...
...
@@ -11,6 +11,17 @@
class
OC_Connector_Sabre_ExceptionLoggerPlugin
extends
Sabre_DAV_ServerPlugin
{
private
$nonFatalExceptions
=
array
(
'Sabre_DAV_Exception_NotAuthenticated'
=>
true
,
// the sync client uses this to find out whether files exist,
// so it is not always an error, log it as debug
'Sabre_DAV_Exception_NotFound'
=>
true
,
// this one mostly happens when the same file is uploaded at
// exactly the same time from two clients, only one client
// wins, the second one gets "Precondition failed"
'Sabre_DAV_Exception_PreconditionFailed'
=>
true
,
);
private
$appName
;
/**
...
...
@@ -43,8 +54,10 @@ class OC_Connector_Sabre_ExceptionLoggerPlugin extends Sabre_DAV_ServerPlugin
*/
public
function
logException
(
$e
)
{
$exceptionClass
=
get_class
(
$e
);
if
(
$exceptionClass
!==
'Sabre_DAV_Exception_NotAuthenticated'
)
{
\OCP\Util
::
logException
(
$this
->
appName
,
$e
);
$level
=
\OCP\Util
::
FATAL
;
if
(
isset
(
$this
->
nonFatalExceptions
[
$exceptionClass
]))
{
$level
=
\OCP\Util
::
DEBUG
;
}
\OCP\Util
::
logException
(
$this
->
appName
,
$e
,
$level
);
}
}
This diff is collapsed.
Click to expand it.
lib/public/util.php
+
5
−
4
View file @
4a493c88
...
...
@@ -86,21 +86,22 @@ class Util {
* if DEBUG mode is enabled
* @param string $app app name
* @param \Exception $ex exception to log
* @param string $level log level, defaults to \OCP\Util::FATAL
*/
public
static
function
logException
(
$app
,
\Exception
$ex
)
{
public
static
function
logException
(
$app
,
\Exception
$ex
,
$level
=
\OCP\Util
::
FATAL
)
{
$class
=
get_class
(
$ex
);
$message
=
$class
.
': '
.
$ex
->
getMessage
();
if
(
$ex
->
getCode
())
{
$message
.
=
' ['
.
$ex
->
getCode
()
.
']'
;
}
\OCP\Util
::
writeLog
(
$app
,
$message
,
\OCP\Util
::
FATAL
);
\OCP\Util
::
writeLog
(
$app
,
$message
,
$level
);
if
(
defined
(
'DEBUG'
)
and
DEBUG
)
{
// also log stack trace
$stack
=
explode
(
"
\n
"
,
$ex
->
getTraceAsString
());
// first element is empty
array_shift
(
$stack
);
foreach
(
$stack
as
$s
)
{
\OCP\Util
::
writeLog
(
$app
,
'Exception: '
.
$s
,
\OCP\Util
::
FATAL
);
\OCP\Util
::
writeLog
(
$app
,
'Exception: '
.
$s
,
$level
);
}
// include cause
...
...
@@ -110,7 +111,7 @@ class Util {
if
(
$ex
->
getCode
())
{
$message
.
=
'['
.
$ex
->
getCode
()
.
'] '
;
}
\OCP\Util
::
writeLog
(
$app
,
'Exception: '
.
$message
,
\OCP\Util
::
FATAL
);
\OCP\Util
::
writeLog
(
$app
,
'Exception: '
.
$message
,
$level
);
}
}
}
...
...
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