Bot-detector / Bot-Detector-Core-Files

The server and processing files for the Bot Detector Plugin
GNU General Public License v3.0
18 stars 15 forks source link

Replace Hard-coded Route Logging Strings #450

Closed ThorntonMatthewD closed 2 years ago

ThorntonMatthewD commented 2 years ago

Replace Hard-coded Route Logging Strings

Fixes #446

Description:

This PR aimed to alleviate the need to manually format and maintain log strings for numerous verify_token calls within routes, and to instead allow Starlette's Request class to handle the heavy lifting.

The build_route_log_string method does exactly what it sounds like- it accepts a Request object along with a list of strings that you would like to not show up in the logs (tokens, anyone?), and generates a string for the logs. The output will be something similar to as follows:

"[POST] Path: /1.3.2/site/discord_user/*** Query Params: test=true"

The *** portion of the string is a substring that was elected to be censored.

This will allow us to keep the log formatting synchronized across all routes and make it a breeze to adjust it as necessary.

Other Changes