Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
ui-middleware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue 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
Open Source Software
OX App Suite
Core
ui-middleware
Commits
dfbe69af
Commit
dfbe69af
authored
1 year ago
by
bjoern.koester
Browse files
Options
Downloads
Patches
Plain Diff
Fix: OXUI-1330: Log aggregate errors seperately
parent
1e391b45
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/files.js
+1
-1
1 addition, 1 deletion
src/files.js
src/plugins/logging.js
+0
-46
0 additions, 46 deletions
src/plugins/logging.js
src/routes/autohooks.js
+5
-4
5 additions, 4 deletions
src/routes/autohooks.js
with
6 additions
and
51 deletions
src/files.js
+
1
−
1
View file @
dfbe69af
...
...
@@ -88,7 +88,7 @@ export async function fetchFileWithHeaders ({ path, version }) {
return
fetchFileWithHeadersFromBaseUrl
({
path
,
baseUrl
,
version
})
}
catch
(
err
)
{
logger
.
debug
(
`[Files] File
${
path
}
had a baseUrl but could not be found on that server:
${
err
}
`
)
if
(
err
instanceof
VersionMismatchError
)
throw
err
if
(
is
VersionMismatchError
(
err
)
)
throw
err
}
}
...
...
This diff is collapsed.
Click to expand it.
src/plugins/logging.js
deleted
100644 → 0
+
0
−
46
View file @
1e391b45
/*
*
* @copyright Copyright (c) OX Software GmbH, Germany <info@open-xchange.com>
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with OX App Suite. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
*
* Any use of the work other than as authorized under this license or copyright law is prohibited.
*
*/
import
fp
from
'
fastify-plugin
'
// This plugin is used to log requests and responses.
export
default
fp
(
async
(
fastify
)
=>
{
// Logs the request body with the 'trace' level
fastify
.
addHook
(
'
preHandler
'
,
function
(
req
,
reply
,
done
)
{
if
(
req
.
body
)
req
.
log
.
trace
({
body
:
req
.
body
},
'
parsed body
'
)
done
()
})
fastify
.
addHook
(
'
onError
'
,
(
req
,
reply
,
{
message
,
stack
,
statusCode
},
done
)
=>
{
const
error
=
{
statusCode
,
stack
}
reply
.
log
.
error
(
error
,
message
||
'
request errored
'
)
done
()
})
// Logs the request with the 'debug' level and also logs headers with the 'trace' level
fastify
.
addHook
(
'
onResponse
'
,
(
req
,
reply
,
done
)
=>
{
const
loggingOptions
=
{
url
:
req
.
raw
.
url
,
res
:
reply
,
responseTime
:
reply
.
getResponseTime
()
}
if
(
process
.
env
.
LOG_LEVEL
===
'
trace
'
)
loggingOptions
.
headers
=
req
.
headers
reply
.
log
.
debug
(
loggingOptions
,
'
request completed
'
)
done
()
})
})
This diff is collapsed.
Click to expand it.
src/routes/autohooks.js
+
5
−
4
View file @
dfbe69af
...
...
@@ -30,13 +30,14 @@ export default async function (app, opts) {
reply
.
header
(
'
version
'
,
version
)
reply
.
header
(
'
latest-version
'
,
latestVersion
)
reply
.
version
=
version
if
(
req
.
body
)
req
.
log
.
trace
({
body
:
req
.
body
},
'
parsed body
'
)
})
// Add a hook to log errors
app
.
addHook
(
'
onError
'
,
(
req
,
reply
,
{
message
,
stack
,
statusCode
}
,
done
)
=>
{
const
error
=
{
statusCode
,
stack
}
/* c8 ignore next */
reply
.
log
.
error
(
error
,
message
||
'
request errored
'
)
app
.
addHook
(
'
onError
'
,
(
req
,
reply
,
fastifyError
,
done
)
=>
{
// @ts-ignore - AggregateError is not yet part of the types
const
aggregatedErrors
=
fastifyError
.
errors
instanceof
Array
?
fastifyError
.
errors
:
[
fastifyError
]
aggregatedErrors
.
forEach
(
error
=>
error
.
err
?
reply
.
log
.
error
(
error
,
error
.
err
.
message
)
:
reply
.
log
.
error
(
error
,
error
.
message
||
'
request errored
'
)
)
done
()
})
...
...
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