From e05ebe8f9b032d425d1724d6f75f897e98bd560c Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Thu, 27 Oct 2022 14:25:55 +0200 Subject: [PATCH] src: print nghttp2 logs when using --debug-nghttp2 PR-URL: https://github.com/nodejs/node/pull/45209 Reviewed-By: Richard Lau Reviewed-By: Rafael Gonzaga Reviewed-By: Luigi Pinca Reviewed-By: Yagiz Nizipli --- node.gyp | 3 +++ src/node_http2.cc | 10 ++++++++++ 2 files changed, 13 insertions(+) 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