Skip to content

Instantly share code, notes, and snippets.

@alexvdvalk
Last active February 4, 2026 17:09
Show Gist options
  • Select an option

  • Save alexvdvalk/8deb07aa74ea335c318b78007cef1b16 to your computer and use it in GitHub Desktop.

Select an option

Save alexvdvalk/8deb07aa74ea335c318b78007cef1b16 to your computer and use it in GitHub Desktop.
Add additional logging to Directus console.
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