diff --git a/node.gyp b/node.gyp index dffcce4c1308f3..642592fa246e51 100644 --- a/node.gyp +++ b/node.gyp @@ -933,6 +933,9 @@ }, ], }], + [ 'debug_nghttp2==1', { + 'defines': [ 'NODE_DEBUG_NGHTTP2=1' ] + }], ], 'actions': [ { diff --git a/src/node_http2.cc b/src/node_http2.cc index f87c9811a6375b..4ab485018c656b 100644 --- a/src/node_http2.cc +++ b/src/node_http2.cc @@ -3179,6 +3179,12 @@ void SetCallbackFunctions(const FunctionCallbackInfo& args) { #undef SET_FUNCTION } +#ifdef NODE_DEBUG_NGHTTP2 +void NgHttp2Debug(const char* format, va_list args) { + vfprintf(stderr, format, args); +} +#endif + void Http2State::MemoryInfo(MemoryTracker* tracker) const { tracker->TrackField("root_buffer", root_buffer); } @@ -3344,6 +3350,10 @@ void Initialize(Local target, #undef V target->Set(context, env->constants_string(), constants).Check(); + +#ifdef NODE_DEBUG_NGHTTP2 + nghttp2_set_debug_vprintf_callback(NgHttp2Debug); +#endif } } // namespace http2 } // namespace node