forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "http2: removes environment variable-triggered nghttp2 logging (…
…envoyproxy#34354)" (envoyproxy#34876) This reverts commit 14cd80f. Signed-off-by: Yan Avlasov <[email protected]> Signed-off-by: Fernando Cainelli <[email protected]>
- Loading branch information
1 parent
0827ad6
commit 064bf5b
Showing
6 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include "source/common/http/http2/nghttp2.h" | ||
|
||
#include "source/common/common/logger.h" | ||
|
||
// nghttp2 fails to convey the POSIX ssize_t declaration | ||
// that Microsoft declines to implement. Pick up a valid | ||
// ssize_t declaration for win32 in our platform.h | ||
#include "envoy/common/platform.h" | ||
|
||
#include "nghttp2/nghttp2.h" | ||
|
||
namespace Envoy { | ||
namespace Http { | ||
namespace Http2 { | ||
|
||
void initializeNghttp2Logging() { | ||
// When ENVOY_NGHTTP2_TRACE is set, we install a debug logger, to prevent nghttp2 | ||
// logging directly to stdout at -l trace. | ||
nghttp2_set_debug_vprintf_callback([](const char* format, va_list args) { | ||
if (std::getenv("ENVOY_NGHTTP2_TRACE") != nullptr) { | ||
char buf[2048]; | ||
const int n = ::vsnprintf(buf, sizeof(buf), format, args); | ||
// nghttp2 inserts new lines, but we also insert a new line in the ENVOY_LOG | ||
// below, so avoid double \n. | ||
if (n >= 1 && static_cast<size_t>(n) < sizeof(buf) && buf[n - 1] == '\n') { | ||
buf[n - 1] = '\0'; | ||
} | ||
ENVOY_LOG_TO_LOGGER(Logger::Registry::getLog(Logger::Id::http2), trace, "nghttp2: {}", buf); | ||
} | ||
}); | ||
} | ||
|
||
} // namespace Http2 | ||
} // namespace Http | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#pragma once | ||
|
||
namespace Envoy { | ||
namespace Http { | ||
namespace Http2 { | ||
|
||
/** | ||
* Setup nghttp2 trace-level logging for when debugging. | ||
*/ | ||
void initializeNghttp2Logging(); | ||
|
||
} // namespace Http2 | ||
} // namespace Http | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters