Github   Telegram
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
server::handlers::DynamicDebugLog Class Referencefinal

Handler for forcing specific lines logging. Feature also known as dynamic debug logging. More...

#include <userver/server/handlers/dynamic_debug_log.hpp>

+ Inheritance diagram for server::handlers::DynamicDebugLog:
+ Collaboration diagram for server::handlers::DynamicDebugLog:

Public Member Functions

 DynamicDebugLog (const components::ComponentConfig &config, const components::ComponentContext &component_context)
 
std::string HandleRequestThrow (const http::HttpRequest &request, request::RequestContext &) const override
 
- Public Member Functions inherited from server::handlers::HttpHandlerBase
 HttpHandlerBase (const components::ComponentConfig &config, const components::ComponentContext &component_context, bool is_monitor=false)
 
void HandleRequest (request::RequestBase &request, request::RequestContext &context) const override
 
void ReportMalformedRequest (request::RequestBase &request) const final
 
virtual const std::string & HandlerName () const
 
const std::vector< http::HttpMethod > & GetAllowedMethods () const
 
virtual logging::Level GetLogLevelForResponseStatus (http::HttpStatus status) const
 
virtual FormattedErrorData GetFormattedExternalErrorBody (const CustomHandlerException &exc) const
 
std::string GetResponseDataForLoggingChecked (const http::HttpRequest &request, request::RequestContext &context, const std::string &response_data) const
 
- Public Member Functions inherited from server::handlers::HandlerBase
 HandlerBase (const components::ComponentConfig &config, const components::ComponentContext &component_context, bool is_monitor=false)
 
virtual void HandleRequest (request::RequestBase &request, request::RequestContext &context) const =0
 
virtual void ReportMalformedRequest (request::RequestBase &) const
 
bool IsMonitor () const
 Returns whether this is a monitoring handler. More...
 
const HandlerConfigGetConfig () const
 Returns handler config.
 
- Public Member Functions inherited from components::LoggableComponentBase
 LoggableComponentBase (const ComponentConfig &, const ComponentContext &)
 
 LoggableComponentBase (LoggableComponentBase &&)=delete
 
 LoggableComponentBase (const LoggableComponentBase &)=delete
 
 ~LoggableComponentBase () override=default
 
ComponentHealth GetComponentHealth () const override
 
void OnLoadingCancelled () override
 
void OnAllComponentsLoaded () override
 
void OnAllComponentsAreStopping () override
 

Static Public Member Functions

static yaml_config::Schema GetStaticConfigSchema ()
 
- Static Public Member Functions inherited from server::handlers::HttpHandlerBase
static yaml_config::Schema GetStaticConfigSchema ()
 
- Static Public Member Functions inherited from server::handlers::HandlerBase
static yaml_config::Schema GetStaticConfigSchema ()
 
- Static Public Member Functions inherited from components::LoggableComponentBase
static yaml_config::Schema GetStaticConfigSchema ()
 

Static Public Attributes

static constexpr std::string_view kName = "handler-dynamic-debug-log"
 

Additional Inherited Members

- Protected Types inherited from server::handlers::HandlerBase
using HandlerErrorCode = handlers::HandlerErrorCode
 
using InternalMessage = handlers::InternalMessage
 
using ExternalBody = handlers::ExternalBody
 
using ClientError = handlers::ClientError
 
using InternalServerError = handlers::InternalServerError
 
- Protected Member Functions inherited from server::handlers::HttpHandlerBase
void ThrowUnsupportedHttpMethod (const http::HttpRequest &request) const
 
virtual std::string HandleRequestThrow (const http::HttpRequest &request, request::RequestContext &context) const
 
virtual void OnRequestCompleteThrow (const http::HttpRequest &, request::RequestContext &) const
 
virtual void HandleStreamRequest (const server::http::HttpRequest &, server::request::RequestContext &, server::http::ResponseBodyStream &) const
 
virtual bool IsStreamed () const
 
virtual bool IsMethodStatisticIncluded () const
 
virtual bool NeedCheckAuth () const
 
virtual std::string GetRequestBodyForLogging (const http::HttpRequest &request, request::RequestContext &context, const std::string &request_body) const
 Override it if you need a custom request body logging. More...
 
virtual std::string GetResponseDataForLogging (const http::HttpRequest &request, request::RequestContext &context, const std::string &response_data) const
 Override it if you need a custom response data logging. More...
 
virtual void ParseRequestData (const http::HttpRequest &, request::RequestContext &) const
 
virtual std::string GetMetaType (const http::HttpRequest &) const
 

Detailed Description

Handler for forcing specific lines logging. Feature also known as dynamic debug logging.

The component has no service configuration except the common handler options.

Static configuration example:

handler-dynamic-debug-log:
path: /service/log/dynamic-debug
method: GET,PUT,DELETE
task_processor: monitor-task-processor

Scheme

GET request shows information about available locations and forced loggings. PUT adds forced logging for a particular location. DELETE request removes forced logging from a location.

GET

For the GET requests this handler returns a list of all the known logging locations tab separated from a on/off value of logging:

project/src/some.cpp:13 0
project/src/some.cpp:23 0
project/src/some.cpp:42 1
project/src/some.cpp:113 0
userver/core/src/server/server.cpp:131 0

In the above sample 1 means that logging was enabled via this handler and that logger would write logs even if the logger level tells not to do that. 0 means that the log will be written down only if the logger level tells to do that.

PUT

PUT request enables logging for the location specified in a location= argument in URL. PUT request should have a location= argument in URL with a location from the GET request or with a location without line number, to enable logging for the whole file.

DELETE

DELETE request removes the forced logging from location. Location should be specified in the location= argument in URL.

See also
Changing the log level at runtime

Definition at line 63 of file dynamic_debug_log.hpp.

Member Function Documentation

◆ HandleRequestThrow()

std::string server::handlers::DynamicDebugLog::HandleRequestThrow ( const http::HttpRequest request,
request::RequestContext  
) const
overridevirtual

Reimplemented from server::handlers::HttpHandlerBase.

Member Data Documentation

◆ kName

constexpr std::string_view server::handlers::DynamicDebugLog::kName = "handler-dynamic-debug-log"
staticconstexpr

Definition at line 68 of file dynamic_debug_log.hpp.


The documentation for this class was generated from the following file: