| | | 1 | | using System.Text.Json; |
| | | 2 | | |
| | | 3 | | namespace Services.ApiServices.OzonApi; |
| | | 4 | | |
| | | 5 | | /// <summary>NDJSON-логи polling Ozon report API (debug-сессия).</summary> |
| | | 6 | | internal static class OzonReportDebugLog |
| | | 7 | | { |
| | | 8 | | private const string LogPath = "/Users/evgen/RiderProjects/Studio2Prod/.cursor/debug-3b6abe.log"; |
| | | 9 | | |
| | | 10 | | public static void Write(string checkpoint, object data) |
| | | 11 | | { |
| | | 12 | | try |
| | | 13 | | { |
| | 0 | 14 | | var line = JsonSerializer.Serialize(new |
| | 0 | 15 | | { |
| | 0 | 16 | | sessionId = "3b6abe", |
| | 0 | 17 | | hypothesisId = "OZON-REPORT", |
| | 0 | 18 | | fixId = "FIX-1", |
| | 0 | 19 | | location = "OzonApi:" + checkpoint, |
| | 0 | 20 | | message = checkpoint, |
| | 0 | 21 | | data, |
| | 0 | 22 | | timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), |
| | 0 | 23 | | runId = "ozon-report-poll" |
| | 0 | 24 | | }); |
| | 0 | 25 | | File.AppendAllText(LogPath, line + Environment.NewLine); |
| | 0 | 26 | | } |
| | 0 | 27 | | catch |
| | | 28 | | { |
| | | 29 | | // best-effort |
| | 0 | 30 | | } |
| | 0 | 31 | | } |
| | | 32 | | |
| | | 33 | | public static string Truncate(string? value, int max = 500) => |
| | 0 | 34 | | string.IsNullOrEmpty(value) ? string.Empty |
| | 0 | 35 | | : value.Length <= max ? value |
| | 0 | 36 | | : value[..max] + "…"; |
| | | 37 | | } |