using aaLogReader;

namespace AaLog.Cli.Output
{
    /// LLM-friendly subset of the underlying aaLogReader record. Drops file-format
    /// internals (record length, offsets) and the date/time/millis triple that is
    /// redundant with the full ISO-8601 timestamps.
    public class LogRecordDto
    {
        public ulong MessageNumber { get; init; }
        public string TimestampUtc { get; init; }
        public string TimestampLocal { get; init; }
        public string Level { get; init; }
        public string Component { get; init; }
        public string ProcessName { get; init; }
        public uint ProcessId { get; init; }
        public uint ThreadId { get; init; }
        public string SessionId { get; init; }
        public string Host { get; init; }
        public string Message { get; init; }

        public static LogRecordDto From(LogRecord r) => new LogRecordDto
        {
            MessageNumber = r.MessageNumber,
            TimestampUtc = r.EventDateTimeUtc.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"),
            TimestampLocal = r.EventDateTimeLocal.ToString("yyyy-MM-ddTHH:mm:ss.fff"),
            Level = r.LogFlag,
            Component = r.Component,
            ProcessName = r.ProcessName,
            ProcessId = r.ProcessID,
            ThreadId = r.ThreadID,
            SessionId = r.SessionID,
            Host = r.HostFQDN,
            Message = r.Message,
        };
    }
}
