< Summary

Information
Class: Services.ApiServices.OzonApi.OzonReportDebugLog
Assembly: Services
File(s): /home/runner/work/Studio2Prod/Studio2Prod/AppRepository/ApiServices/OzonApi/OzonReportDebugLog.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 19
Coverable lines: 19
Total lines: 37
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Write(...)100%210%
Truncate(...)0%2040%

File(s)

/home/runner/work/Studio2Prod/Studio2Prod/AppRepository/ApiServices/OzonApi/OzonReportDebugLog.cs

#LineLine coverage
 1using System.Text.Json;
 2
 3namespace Services.ApiServices.OzonApi;
 4
 5/// <summary>NDJSON-логи polling Ozon report API (debug-сессия).</summary>
 6internal 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        {
 014            var line = JsonSerializer.Serialize(new
 015            {
 016                sessionId = "3b6abe",
 017                hypothesisId = "OZON-REPORT",
 018                fixId = "FIX-1",
 019                location = "OzonApi:" + checkpoint,
 020                message = checkpoint,
 021                data,
 022                timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
 023                runId = "ozon-report-poll"
 024            });
 025            File.AppendAllText(LogPath, line + Environment.NewLine);
 026        }
 027        catch
 28        {
 29            // best-effort
 030        }
 031    }
 32
 33    public static string Truncate(string? value, int max = 500) =>
 034        string.IsNullOrEmpty(value) ? string.Empty
 035        : value.Length <= max ? value
 036        : value[..max] + "…";
 37}