You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With fastify-static I'm not able to use this feature.
I don't know if I'm doing something wrong but looking to the source code I can actually see that logLevel in not propagate to routes created by this plugin.
Motivation
I'm in a scenario in which clients are calling an API that it's exposing a resource that drive browsers/clients to static contents that we are serving trough fastify-static plugin.
I would like to avoid logging every time that a client is asking for our "main" API other 5, 10, 100 log lines for the static contents that consequentially they will ask to our server.
That's why I would like to server static contents with an higher log level by default.
Then eventually if for debugging purpose we need those log it's just the matter of a configuration change.
Example
In order to reproduce it just populate logLevel into plugin's options:
(starting from: example/server.js)
'use strict'constpath=require('node:path')constfastify=require('fastify')({logger: {level: 'trace'}})fastify.register(require('../'),{// An absolute path containing static files to serve.root: path.join(__dirname,'/public'),logLevel: 'warn'}).listen({port: 3000},err=>{if(err)throwerr})
I would expect to not see any log line, instead this is the output:
Prerequisites
🚀 Feature Proposal
Looking at fastify's documentation I can found that plugins should accept and propagate (under the correct conditions) logLevel, for example by setting custom log level: https://fastify.dev/docs/latest/Reference/Routes/#custom-log-level
With fastify-static I'm not able to use this feature.
I don't know if I'm doing something wrong but looking to the source code I can actually see that logLevel in not propagate to routes created by this plugin.
Motivation
I'm in a scenario in which clients are calling an API that it's exposing a resource that drive browsers/clients to static contents that we are serving trough fastify-static plugin.
I would like to avoid logging every time that a client is asking for our "main" API other 5, 10, 100 log lines for the static contents that consequentially they will ask to our server.
That's why I would like to server static contents with an higher log level by default.
Then eventually if for debugging purpose we need those log it's just the matter of a configuration change.
Example
In order to reproduce it just populate
logLevel
into plugin's options:(starting from: example/server.js)
I would expect to not see any log line, instead this is the output:
The text was updated successfully, but these errors were encountered: