Skip to content

Commit e05ebe8

Browse files
santigimenodanielleadams
authored andcommitted
src: print nghttp2 logs when using --debug-nghttp2
PR-URL: #45209 Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
1 parent 61bc27a commit e05ebe8

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

node.gyp

+3
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,9 @@
933933
},
934934
],
935935
}],
936+
[ 'debug_nghttp2==1', {
937+
'defines': [ 'NODE_DEBUG_NGHTTP2=1' ]
938+
}],
936939
],
937940
'actions': [
938941
{

src/node_http2.cc

+10
Original file line numberDiff line numberDiff line change
@@ -3179,6 +3179,12 @@ void SetCallbackFunctions(const FunctionCallbackInfo<Value>& args) {
31793179
#undef SET_FUNCTION
31803180
}
31813181

3182+
#ifdef NODE_DEBUG_NGHTTP2
3183+
void NgHttp2Debug(const char* format, va_list args) {
3184+
vfprintf(stderr, format, args);
3185+
}
3186+
#endif
3187+
31823188
void Http2State::MemoryInfo(MemoryTracker* tracker) const {
31833189
tracker->TrackField("root_buffer", root_buffer);
31843190
}
@@ -3344,6 +3350,10 @@ void Initialize(Local<Object> target,
33443350
#undef V
33453351

33463352
target->Set(context, env->constants_string(), constants).Check();
3353+
3354+
#ifdef NODE_DEBUG_NGHTTP2
3355+
nghttp2_set_debug_vprintf_callback(NgHttp2Debug);
3356+
#endif
33473357
}
33483358
} // namespace http2
33493359
} // namespace node

0 commit comments

Comments
 (0)