(self, record)
| 376 | # self.filtered_paths = ["/health", "/webui/"] |
| 377 | |
| 378 | def filter(self, record): |
| 379 | try: |
| 380 | # Check if record has the required attributes for an access log |
| 381 | if not hasattr(record, "args") or not isinstance(record.args, tuple): |
| 382 | return True |
| 383 | if len(record.args) < 5: |
| 384 | return True |
| 385 | |
| 386 | # Extract method, path and status from the record args |
| 387 | method = record.args[1] |
| 388 | path = record.args[2] |
| 389 | status = record.args[4] |
| 390 | |
| 391 | # Filter out successful GET/POST requests to filtered paths |
| 392 | if ( |
| 393 | (method == "GET" or method == "POST") |
| 394 | and (status == 200 or status == 304) |
| 395 | and path in self.filtered_paths |
| 396 | ): |
| 397 | return False |
| 398 | |
| 399 | return True |
| 400 | except Exception: |
| 401 | # In case of any error, let the message through |
| 402 | return True |
| 403 | |
| 404 | |
| 405 | def setup_logger( |
no outgoing calls
no test coverage detected