Skip to content

Commit 4307725

Browse files
santigimenolucshi
authored and
lucshi
committed
src: print nghttp2 logs when using --debug-nghttp2
PR-URL: nodejs#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 34122f4 commit 4307725

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
@@ -860,6 +860,9 @@
860860
},
861861
],
862862
}],
863+
[ 'debug_nghttp2==1', {
864+
'defines': [ 'NODE_DEBUG_NGHTTP2=1' ]
865+
}],
863866
],
864867
'actions': [
865868
{

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)