namespace ROLAC.API.Entities.Logging;

/// <summary>
/// An append-only operational log row — one per persisted framework/app log event,
/// including every unhandled API exception captured by ExceptionHandlingMiddleware.
/// Intentionally does NOT inherit AuditableEntity: these rows are never updated and
/// must not be re-stamped or re-audited (that would recurse through the log pipeline).
/// </summary>
public class SystemLog
{
    public long           Id            { get; set; }
    public DateTimeOffset Timestamp     { get; set; }
    public LogLevelEnum   Level         { get; set; }

    /// <summary>The ILogger category (source), e.g. "ROLAC.API.Controllers.GivingsController".</summary>
    public string         Category      { get; set; } = null!;
    public int?           EventId       { get; set; }
    public string         Message       { get; set; } = null!;

    /// <summary>Full <c>exception.ToString()</c> (type + message + stack), when present.</summary>
    public string?        Exception     { get; set; }

    public string?        RequestPath   { get; set; }
    public string?        HttpMethod    { get; set; }
    public int?           StatusCode    { get; set; }

    /// <summary>The acting user id ("sub" claim), or null for background/system events.</summary>
    public string?        UserId        { get; set; }
    public string?        IpAddress     { get; set; }
    public string?        CorrelationId { get; set; }
}
