From 5e74cb60767b23f028ec4a06fbf293f9a8120e44 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 a3ae91c90124de..a22af3b479aadf 100644 --- a/node.gyp +++ b/node.gyp @@ -859,6 +859,9 @@ }, ], }], + [ 'debug_nghttp2==1', { + 'defines': [ 'NODE_DEBUG_NGHTTP2=1' ] + }], ], 'actions': [ { diff --git a/src/node_http2.cc b/src/node_http2.cc index f8f8af3a3dc2e6..fe66f9761d0c70 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