/// <inheritdoc /> public void WriteTo(Utf8JsonWriter writer) { writer.WriteStartObject(); // Env if (InternalEnv is {} env&& env.Any()) { writer.WriteDictionary("env", env !); } // Other if (InternalOther is {} other&& other.Any()) { writer.WriteDictionary("other", other !); } // Headers if (InternalHeaders is {} headers&& headers.Any()) { writer.WriteDictionary("headers", headers !); } // Url if (!string.IsNullOrWhiteSpace(Url)) { writer.WriteString("url", Url); } // Method if (!string.IsNullOrWhiteSpace(Method)) { writer.WriteString("method", Method); } // Data if (Data is {} data) { writer.WriteDynamic("data", data); } // Query if (!string.IsNullOrWhiteSpace(QueryString)) { writer.WriteString("query_string", QueryString); } // Cookies if (!string.IsNullOrWhiteSpace(Cookies)) { writer.WriteString("cookies", Cookies); } writer.WriteEndObject(); }
/// <inheritdoc /> public void WriteTo(Utf8JsonWriter writer) { writer.WriteStartObject(); // Timestamp writer.WriteString( "timestamp", Timestamp.ToString("yyyy-MM-ddTHH\\:mm\\:ss.fffZ", DateTimeFormatInfo.InvariantInfo) ); // Message if (!string.IsNullOrWhiteSpace(Message)) { writer.WriteString("message", Message); } // Type if (!string.IsNullOrWhiteSpace(Type)) { writer.WriteString("type", Type); } // Data if (Data is { } data) { // Why is ! required here? No idea writer.WriteDictionary("data", data !); } // Category if (!string.IsNullOrWhiteSpace(Category)) { writer.WriteString("category", Category); } // Level if (Level != default) { writer.WriteString("level", Level.ToString().ToLowerInvariant()); } writer.WriteEndObject(); }
/// <inheritdoc /> public void WriteTo(Utf8JsonWriter writer) { writer.WriteStartObject(); // Pre-context if (InternalPreContext is {} preContext&& preContext.Any()) { writer.WriteStartArray("pre_context"); foreach (var i in preContext) { writer.WriteStringValue(i); } writer.WriteEndArray(); } // Post-context if (InternalPostContext is {} postContext&& postContext.Any()) { writer.WriteStartArray("post_context"); foreach (var i in postContext) { writer.WriteStringValue(i); } writer.WriteEndArray(); } // Vars if (InternalVars is {} vars&& vars.Any()) { writer.WriteDictionary("vars", vars !); } // Frames omitted if (InternalFramesOmitted is {} framesOmitted&& framesOmitted.Any()) { writer.WriteStartArray("frames_omitted"); foreach (var i in framesOmitted) { writer.WriteNumberValue(i); } writer.WriteEndArray(); } // Filename if (!string.IsNullOrWhiteSpace(FileName)) { writer.WriteString("filename", FileName); } // Function if (!string.IsNullOrWhiteSpace(Function)) { writer.WriteString("function", Function); } // Module if (!string.IsNullOrWhiteSpace(Module)) { writer.WriteString("module", Module); } // Line if (LineNumber is {} lineNumber) { writer.WriteNumber("lineno", lineNumber); } // Column if (ColumnNumber is {} columnNumber) { writer.WriteNumber("colno", columnNumber); } // Absolute path if (!string.IsNullOrWhiteSpace(AbsolutePath)) { writer.WriteString("abs_path", AbsolutePath); } // Context line if (!string.IsNullOrWhiteSpace(ContextLine)) { writer.WriteString("context_line", ContextLine); } // In app if (InApp is {} inApp) { writer.WriteBoolean("in_app", inApp); } // Package if (!string.IsNullOrWhiteSpace(Package)) { writer.WriteString("package", Package); } // Platform if (!string.IsNullOrWhiteSpace(Platform)) { writer.WriteString("platform", Platform); } // Image address if (ImageAddress != default) { writer.WriteNumber("image_addr", ImageAddress); } // Symbol address if (SymbolAddress is {} symbolAddress) { writer.WriteNumber("symbol_addr", symbolAddress); } // Instruction address if (!string.IsNullOrWhiteSpace(InstructionAddress)) { writer.WriteString("instruction_addr", InstructionAddress); } // Instruction offset if (InstructionOffset is {} instructionOffset) { writer.WriteNumber("instruction_offset", instructionOffset); } writer.WriteEndObject(); }