@@ -314,7 +314,24 @@ void k2_free_descriptor(uint64_t descriptor);
314314uint8_t k2_take_update (uint64_t * update_d);
315315
316316/* *
317- * Only utf-8 string supported.
317+ * Represents a key-value pair that can be added to a log.
318+ * Each instance of this struct must contain valid, non-null pointers for both the key and the value.
319+ * The lengths of the key and value are specified by `key_len` and `value_len`, respectively.
320+ *
321+ * If an instance is intended to represent only a key without an associated value,
322+ * the `value` pointer should point to an empty string (""), and `value_len` should be set to zero.
323+ */
324+ struct LogKeyValuePair {
325+ const char * key;
326+ const char * value;
327+ size_t key_len;
328+ size_t value_len;
329+ };
330+
331+ /* *
332+ * Writes a structured log message. Only UTF-8 encoded strings are supported.
333+ *
334+ * @param `level` The severity level of the log message.
318335 * Possible `level` values:
319336 * 1 => Error
320337 * 2 => Warn
@@ -323,8 +340,13 @@ uint8_t k2_take_update(uint64_t* update_d);
323340 * 5 => Trace
324341 * Any other value will cause the log to be skipped
325342 * if `level` > `log_level_enabled()` log will be skipped
343+ * @param `len` length of msg in bytes
344+ * @param `msg` A pointer to the log message
345+ * @param `kv_count` The number of key-value pairs.
346+ * @param `kv_pairs` An array of key-value pairs.
326347 */
327- void k2_log (size_t level, size_t len, const char * str);
348+
349+ void k2_log (size_t level, size_t len, const char * msg, size_t kv_count, const struct LogKeyValuePair * kv_pairs);
328350
329351// Use for optimization, see `k2_log`
330352size_t k2_log_level_enabled ();
0 commit comments