mirror of
https://github.com/bitwarden/server.git
synced 2025-02-15 01:41:40 +01:00
log exception strings
This commit is contained in:
parent
efd6a89e34
commit
c63422ea5d
@ -70,7 +70,7 @@ namespace Bit.Admin.Controllers
|
|||||||
_globalSettings.DocumentDb.Key))
|
_globalSettings.DocumentDb.Key))
|
||||||
{
|
{
|
||||||
var uri = UriFactory.CreateDocumentUri(Database, Collection, id.ToString());
|
var uri = UriFactory.CreateDocumentUri(Database, Collection, id.ToString());
|
||||||
var response = await client.ReadDocumentAsync<LogModel>(uri);
|
var response = await client.ReadDocumentAsync<LogDetailsModel>(uri);
|
||||||
if(response?.Document == null)
|
if(response?.Document == null)
|
||||||
{
|
{
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Runtime.Serialization;
|
|
||||||
using Microsoft.Azure.Documents;
|
using Microsoft.Azure.Documents;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json.Linq;
|
||||||
using Serilog.Events;
|
|
||||||
|
|
||||||
namespace Bit.Admin.Models
|
namespace Bit.Admin.Models
|
||||||
{
|
{
|
||||||
@ -14,18 +11,46 @@ namespace Bit.Admin.Models
|
|||||||
public string Message { get; set; }
|
public string Message { get; set; }
|
||||||
public string MessageTruncated => Message.Length > 200 ? $"{Message.Substring(0, 200)}..." : Message;
|
public string MessageTruncated => Message.Length > 200 ? $"{Message.Substring(0, 200)}..." : Message;
|
||||||
public string MessageTemplate { get; set; }
|
public string MessageTemplate { get; set; }
|
||||||
public Error Exception { get; set; }
|
|
||||||
public IDictionary<string, object> Properties { get; set; }
|
public IDictionary<string, object> Properties { get; set; }
|
||||||
public string Project => Properties?.ContainsKey("Project") ?? false ? Properties["Project"].ToString() : null;
|
public string Project => Properties?.ContainsKey("Project") ?? false ? Properties["Project"].ToString() : null;
|
||||||
|
}
|
||||||
|
|
||||||
[JsonObject(MemberSerialization.OptIn)]
|
public class LogDetailsModel : LogModel
|
||||||
public class Error : Exception, ISerializable
|
{
|
||||||
|
public JObject Exception { get; set; }
|
||||||
|
|
||||||
|
public string ExceptionToString(JObject e)
|
||||||
{
|
{
|
||||||
[JsonProperty(PropertyName = "error")]
|
if(e == null)
|
||||||
public string ErrorMessage { get; set; }
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
[JsonConstructor]
|
var val = string.Empty;
|
||||||
public Error() { }
|
if(e["Message"] != null && e["Message"].ToObject<string>() != null)
|
||||||
|
{
|
||||||
|
val += "Message:\n";
|
||||||
|
val += e["Message"] + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(e["StackTrace"] != null && e["StackTrace"].ToObject<string>() != null)
|
||||||
|
{
|
||||||
|
val += "\nStackTrace:\n";
|
||||||
|
val += e["StackTrace"];
|
||||||
|
}
|
||||||
|
else if(e["StackTraceString"] != null && e["StackTraceString"].ToObject<string>() != null)
|
||||||
|
{
|
||||||
|
val += "\nStackTraceString:\n";
|
||||||
|
val += e["StackTraceString"];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(e["InnerException"] != null && e["InnerException"].ToObject<JObject>() != null)
|
||||||
|
{
|
||||||
|
val += "\n\n\n=== Inner Exception ===\n\n\n";
|
||||||
|
val += ExceptionToString(e["InnerException"].ToObject<JObject>());
|
||||||
|
}
|
||||||
|
|
||||||
|
return val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
@model LogModel
|
@model LogDetailsModel
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Log: " + Model.Id;
|
ViewData["Title"] = "Log: " + Model.Id;
|
||||||
}
|
}
|
||||||
@ -26,7 +26,7 @@
|
|||||||
@if(Model.Exception != null)
|
@if(Model.Exception != null)
|
||||||
{
|
{
|
||||||
<h2>Exception</h2>
|
<h2>Exception</h2>
|
||||||
<pre style="max-height: 500px;">@Model.Exception.ToString()</pre>
|
<pre style="max-height: 500px;">@Model.ExceptionToString(Model.Exception)</pre>
|
||||||
}
|
}
|
||||||
|
|
||||||
@if(Model.Properties != null && Model.Properties.Count > 0)
|
@if(Model.Properties != null && Model.Properties.Count > 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user