More logging of resopnse bodies

This commit is contained in:
= 2025-12-14 23:03:22 -05:00
parent aa1b5fe8f1
commit f3ef3e2ef2

View File

@ -270,13 +270,11 @@ public class APIHelper : IAPIHelper
{ {
Console.WriteLine("Exception caught: {0}\n\nStackTrace: {1}", ex.Message, ex.StackTrace); Console.WriteLine("Exception caught: {0}\n\nStackTrace: {1}", ex.Message, ex.StackTrace);
Log.Error("Exception caught: {0}\n\nStackTrace: {1}", ex.Message, ex.StackTrace); Log.Error("Exception caught: {0}\n\nStackTrace: {1}", ex.Message, ex.StackTrace);
DiagnosticLog.Error("PurchasedTab exception | ctx={Context} message={Message} stack={Stack}", diagContext, ex.Message, TruncateString(ex.StackTrace ?? string.Empty, 2000));
if (ex.InnerException != null) if (ex.InnerException != null)
{ {
Console.WriteLine("\nInner Exception:"); Console.WriteLine("\nInner Exception:");
Console.WriteLine("Exception caught: {0}\n\nStackTrace: {1}", ex.InnerException.Message, ex.InnerException.StackTrace); Console.WriteLine("Exception caught: {0}\n\nStackTrace: {1}", ex.InnerException.Message, ex.InnerException.StackTrace);
Log.Error("Inner Exception: {0}\n\nStackTrace: {1}", ex.InnerException.Message, ex.InnerException.StackTrace); Log.Error("Inner Exception: {0}\n\nStackTrace: {1}", ex.InnerException.Message, ex.InnerException.StackTrace);
DiagnosticLog.Error("PurchasedTab inner exception | ctx={Context} message={Message} stack={Stack}", diagContext, ex.InnerException.Message, TruncateString(ex.InnerException.StackTrace ?? string.Empty, 2000));
} }
} }
return null; return null;
@ -2365,6 +2363,7 @@ public class APIHelper : IAPIHelper
else else
{ {
resolvedUsername = userObject[user.Key.ToString()]["username"].ToString(); resolvedUsername = userObject[user.Key.ToString()]["username"].ToString();
DiagnosticLog.Information("PurchasedTab user lookup success | ctx={Context} userId={UserId} username={Username} rawUser={RawUser}", diagContext, user.Key, resolvedUsername, TruncateString(userObject.ToString(), 1500));
} }
purchasedTabCollection.UserId = user.Key; purchasedTabCollection.UserId = user.Key;
purchasedTabCollection.Username = userObject is not null && !string.IsNullOrEmpty(userObject[user.Key.ToString()]["username"].ToString()) ? userObject[user.Key.ToString()]["username"].ToString() : $"Deleted User - {user.Key}"; purchasedTabCollection.Username = userObject is not null && !string.IsNullOrEmpty(userObject[user.Key.ToString()]["username"].ToString()) ? userObject[user.Key.ToString()]["username"].ToString() : $"Deleted User - {user.Key}";
@ -2374,6 +2373,7 @@ public class APIHelper : IAPIHelper
foreach (Purchased.List purchase in user.Value) foreach (Purchased.List purchase in user.Value)
{ {
DiagnosticLog.Information("PurchasedTab processing purchase | ctx={Context} userId={UserId} username={Username} purchaseId={PurchaseId} responseType={ResponseType} mediaNull={MediaNull} mediaCount={MediaCount} postedAt={PostedAt} createdAt={CreatedAt} fromUserId={FromUserId} authorId={AuthorId}", diagContext, user.Key, resolvedUsername, purchase.id, purchase.responseType, purchase.media == null, purchase.media?.Count ?? 0, purchase.postedAt, purchase.createdAt, purchase.fromUser?.id, purchase.author?.id); DiagnosticLog.Information("PurchasedTab processing purchase | ctx={Context} userId={UserId} username={Username} purchaseId={PurchaseId} responseType={ResponseType} mediaNull={MediaNull} mediaCount={MediaCount} postedAt={PostedAt} createdAt={CreatedAt} fromUserId={FromUserId} authorId={AuthorId}", diagContext, user.Key, resolvedUsername, purchase.id, purchase.responseType, purchase.media == null, purchase.media?.Count ?? 0, purchase.postedAt, purchase.createdAt, purchase.fromUser?.id, purchase.author?.id);
DiagnosticLog.Information("PurchasedTab purchase raw | ctx={Context} userId={UserId} username={Username} purchaseId={PurchaseId} responseType={ResponseType} rawPurchase={RawPurchase}", diagContext, user.Key, resolvedUsername, purchase.id, purchase.responseType, TruncateString(JsonConvert.SerializeObject(purchase), 2000));
if (purchase.media == null) if (purchase.media == null)
{ {
DiagnosticLog.Warning("PurchasedTab purchase has null media | ctx={Context} userId={UserId} username={Username} purchaseId={PurchaseId} responseType={ResponseType} rawPurchase={RawPurchase}", diagContext, user.Key, resolvedUsername, purchase.id, purchase.responseType, TruncateString(JsonConvert.SerializeObject(purchase), 1500)); DiagnosticLog.Warning("PurchasedTab purchase has null media | ctx={Context} userId={UserId} username={Username} purchaseId={PurchaseId} responseType={ResponseType} rawPurchase={RawPurchase}", diagContext, user.Key, resolvedUsername, purchase.id, purchase.responseType, TruncateString(JsonConvert.SerializeObject(purchase), 1500));