pairs of name (string) and value
1 import std.stdio : File, stderr; 2 import vibe.data.json : Json, parseJsonString; 3 4 auto origStderr = stderr; 5 stderr = File.tmpfile(); 6 scope (exit) 7 { 8 stderr.close(); 9 stderr = origStderr; 10 } 11 12 logJsonError("error", "mysterious observation", "secret", 42); 13 14 stderr.rewind(); 15 auto observed = parseJsonString(stderr.readln); 16 17 assert(observed["thread"].type == Json.Type.int_); 18 assert(observed["timestamp"].type == Json.Type.int_); 19 assert(observed["error"] == "mysterious observation"); 20 assert(observed["secret"] == 42);
Logs a message in JSON format.