SUPPORT-8703. Доработано логирование запросов
This commit is contained in:
parent
a3c7e63cfc
commit
a6b1c50325
2 changed files with 22 additions and 8 deletions
|
|
@ -146,17 +146,29 @@ typedef fcgi_handler_status_t (*fcgi_request_handler_pt)(const FCGX_Request* req
|
|||
typedef fcgi_request_handler_pt (*FCGI_REQUEST_FINALIZE_HANDLER)(int rc);
|
||||
|
||||
|
||||
static inline void
|
||||
fcgi_print_log(const FCGX_Request* request, const char* status)
|
||||
{
|
||||
const char* uri = fcgi_request_get_param(request, FCGI_PARAM_NAME_REQUEST_URI, NULL);
|
||||
uri = uri != NULL ? uri : "nil";
|
||||
|
||||
const char* method = fcgi_request_get_param(request, FCGI_PARAM_NAME_REQUEST_METHOD, NULL);
|
||||
method = method != NULL ? method : "nil";
|
||||
|
||||
LOG_INFO("%s %s, '%s'", method, uri, status);
|
||||
}
|
||||
|
||||
static inline fcgi_handler_status_t
|
||||
fcgi_200_ok_handler(const FCGX_Request* request, void* ctx __attribute__((unused)))
|
||||
{
|
||||
LOG_INFO("response status: '200 OK'");
|
||||
LOG_DEBUG("response status: '200 OK'");
|
||||
return FCGI_CHECK_PRINTF_STATUS(request, FCGI_200_RESPONSE_FORMAT, 200);
|
||||
}
|
||||
|
||||
static inline fcgi_handler_status_t
|
||||
fcgi_400_bad_request_handler(const FCGX_Request* request, void* ctx __attribute__((unused)))
|
||||
{
|
||||
LOG_INFO("response status: '400 Bad Request'");
|
||||
fcgi_print_log(request, "400 Bad Request");
|
||||
return FCGI_CHECK_PRINTF_STATUS(request, FCGI_400_RESPONSE_FORMAT, 400);
|
||||
}
|
||||
|
||||
|
|
@ -164,7 +176,7 @@ fcgi_400_bad_request_handler(const FCGX_Request* request, void* ctx __attribute_
|
|||
static inline fcgi_handler_status_t
|
||||
fcgi_401_unauthorized_handler(const FCGX_Request* request, void* ctx __attribute__((unused)))
|
||||
{
|
||||
LOG_INFO("response status: '401 Unauthorized'");
|
||||
fcgi_print_log(request, "401 Unauthorized");
|
||||
return FCGI_CHECK_PRINTF_STATUS(request, FCGI_401_RESPONSE_FORMAT, 401);
|
||||
}
|
||||
|
||||
|
|
@ -172,7 +184,7 @@ fcgi_401_unauthorized_handler(const FCGX_Request* request, void* ctx __attribute
|
|||
static inline fcgi_handler_status_t
|
||||
fcgi_404_not_found_handler(const FCGX_Request* request, void* ctx __attribute__((unused)))
|
||||
{
|
||||
LOG_INFO("response status: '404 Not Found'");
|
||||
fcgi_print_log(request, "404 Not Found");
|
||||
return FCGI_CHECK_PRINTF_STATUS(request, FCGI_404_RESPONSE_FORMAT, 404);
|
||||
}
|
||||
|
||||
|
|
@ -180,7 +192,7 @@ fcgi_404_not_found_handler(const FCGX_Request* request, void* ctx __attribute__(
|
|||
static inline fcgi_handler_status_t
|
||||
fcgi_405_method_not_allowed_handler(const FCGX_Request* request, void* ctx __attribute__((unused)))
|
||||
{
|
||||
LOG_INFO("response status: '405 Method Not Allowed'");
|
||||
fcgi_print_log(request, "405 Method Not Allowed");
|
||||
return FCGI_CHECK_PRINTF_STATUS(request, FCGI_405_RESPONSE_FORMAT, 405);
|
||||
}
|
||||
|
||||
|
|
@ -188,7 +200,7 @@ fcgi_405_method_not_allowed_handler(const FCGX_Request* request, void* ctx __att
|
|||
static inline fcgi_handler_status_t
|
||||
fcgi_406_not_acceptable_handler(const FCGX_Request* request, void* ctx __attribute__((unused)))
|
||||
{
|
||||
LOG_INFO("response status: '406 Not Acceptable'");
|
||||
fcgi_print_log(request, "406 Not Acceptable");
|
||||
return FCGI_CHECK_PRINTF_STATUS(request, FCGI_406_RESPONSE_FORMAT, 406);
|
||||
}
|
||||
|
||||
|
|
@ -196,7 +208,7 @@ fcgi_406_not_acceptable_handler(const FCGX_Request* request, void* ctx __attribu
|
|||
static inline fcgi_handler_status_t
|
||||
fcgi_413_request_entity_too_large_handler(const FCGX_Request* request, void* ctx __attribute__((unused)))
|
||||
{
|
||||
LOG_INFO("response status: '413 Request Entity Too Large'");
|
||||
fcgi_print_log(request, "413 Request Entity Too Large'");
|
||||
return FCGI_CHECK_PRINTF_STATUS(request, FCGI_413_RESPONSE_FORMAT, 413);
|
||||
}
|
||||
|
||||
|
|
@ -204,7 +216,7 @@ fcgi_413_request_entity_too_large_handler(const FCGX_Request* request, void* ctx
|
|||
static inline fcgi_handler_status_t
|
||||
fcgi_500_internal_server_error_handler(const FCGX_Request* request, void* ctx __attribute__((unused)))
|
||||
{
|
||||
LOG_ERROR("response status: '500 Internal Server Error'");
|
||||
fcgi_print_log(request, "500 Internal Server Error");
|
||||
return FCGI_CHECK_PRINTF_STATUS(request, FCGI_500_RESPONSE_FORMAT, 500);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -188,6 +188,8 @@ fcgi_401_bad_signature_handler(const FCGX_Request* request, void *ctx)
|
|||
return HANDLER_ERROR;
|
||||
}
|
||||
|
||||
fcgi_print_log(request, "401 Unauthorized");
|
||||
|
||||
return HANDLER_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue