Last active
February 4, 2026 17:09
-
-
Save alexvdvalk/8deb07aa74ea335c318b78007cef1b16 to your computer and use it in GitHub Desktop.
Add additional logging to Directus console.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { defineHook } from '@directus/extensions-sdk'; | |
| export default defineHook((register, context) => { | |
| const { logger } = context; | |
| const { init } = register; | |
| init('middlewares.after', ({ app }) => { | |
| app.use((req, res, next) => { | |
| const userId = req.accountability?.user || 'public'; | |
| logger.info({ | |
| msg: 'Inbound Request', | |
| userId: userId, | |
| method: req.method, | |
| path: req.path, | |
| statusCode: res.statusCode | |
| }); | |
| next(); | |
| }); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment