When the ProfilerMiddleware filename_format argument is a callable, the callable will only receive the WSGI environ variable. However, the default format string can use the elapsed and time values. This means that one using a format function cannot recreate a similar output pattern. In my case, I'd like to use both, but format the timestamp differently.
Example: I'd like a filename of the form 2023-08-21:14:05:05.POST.myurl.13ms.prof. I can get the timestamp by doing my own datetime.now() call, but the elapsed time is not available.
This problem is solvable by subclassing ProfilerMiddleware or writing ones own profiling middleware, but this seems like a useful thing to have in the core library so library users don't need to duplicate the __call__() code in their own projects.
I can submit a PR if this change is welcome.
When the
ProfilerMiddlewarefilename_formatargument is a callable, the callable will only receive the WSGI environ variable. However, the default format string can use theelapsedandtimevalues. This means that one using a format function cannot recreate a similar output pattern. In my case, I'd like to use both, but format the timestamp differently.Example: I'd like a filename of the form
2023-08-21:14:05:05.POST.myurl.13ms.prof. I can get the timestamp by doing my owndatetime.now()call, but the elapsed time is not available.This problem is solvable by subclassing
ProfilerMiddlewareor writing ones own profiling middleware, but this seems like a useful thing to have in the core library so library users don't need to duplicate the__call__()code in their own projects.I can submit a PR if this change is welcome.