Skip to content

Commit e25262d

Browse files
authored
Add support for proxy_get_log_level (#43)
This lets the WASM code determine the log level set for the "wasm" logger on the proxy host, which can be used to optimize when log messages are generated. Signed-off-by: Gregory Brail <[email protected]>
1 parent a23dadb commit e25262d

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

proxy_wasm_api.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,9 @@ class ContextBase {
289289
// Called when a foreign function event arrives.
290290
virtual void onForeignFunction(uint32_t /* foreign_function_id */, uint32_t /* data_size */) {}
291291

292+
// Return the log level configured for the "wasm" logger in the host
293+
WasmResult getLogLevel(LogLevel *level) { return proxy_get_log_level(level); }
294+
292295
using HttpCallCallback =
293296
std::function<void(uint32_t, size_t, uint32_t)>; // headers, body_size, trailers
294297
using GrpcSimpleCallCallback = std::function<void(GrpcStatus status, size_t body_size)>;

proxy_wasm_externs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ extern "C" WasmResult proxy_get_status(uint32_t *status_code_ptr, const char **m
3737

3838
// Logging
3939
extern "C" WasmResult proxy_log(LogLevel level, const char *logMessage, size_t messageSize);
40+
extern "C" WasmResult proxy_get_log_level(LogLevel *level);
4041

4142
// Timer (will be set for the root context, e.g. onStart, onTick).
4243
extern "C" WasmResult proxy_set_tick_period_milliseconds(uint32_t millisecond);

proxy_wasm_intrinsics.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
mergeInto(LibraryManager.library, {
1919
proxy_get_configuration: function() {},
2020
proxy_log: function() {},
21+
proxy_get_log_level: function() {},
2122
proxy_set_tick_period_milliseconds: function() {},
2223
proxy_get_current_time_nanoseconds: function() {},
2324
proxy_get_status: function() {},

0 commit comments

Comments
 (0)