package com.common.entity;

import java.time.OffsetDateTime;
import java.util.HashMap;
import java.util.Map;

// 基础 Syslog 消息类
public abstract class SyslogMessage {
    protected int priority;
    protected int facility;
    protected int severity;
    protected String hostname;
    protected String appName;
    protected String procId;
    protected String msgId;
    protected String message;
    protected OffsetDateTime timestamp;

    // Getters and Setters
    public int getPriority() { return priority; }
    public void setPriority(int priority) {
        this.priority = priority;
        this.facility = priority / 8;
        this.severity = priority % 8;
    }

    public int getFacility() { return facility; }
    public int getSeverity() { return severity; }
    public String getHostname() { return hostname; }
    public void setHostname(String hostname) { this.hostname = hostname; }
    public String getAppName() { return appName; }
    public void setAppName(String appName) { this.appName = appName; }
    public String getProcId() { return procId; }
    public void setProcId(String procId) { this.procId = procId; }
    public String getMsgId() { return msgId; }
    public void setMsgId(String msgId) { this.msgId = msgId; }
    public String getMessage() { return message; }
    public void setMessage(String message) { this.message = message; }
    public OffsetDateTime getTimestamp() { return timestamp; }
    public void setTimestamp(OffsetDateTime timestamp) { this.timestamp = timestamp; }

    @Override
    public String toString() {
        return String.format("Facility: %d, Severity: %d, Host: %s, App: %s, Time: %s, Msg: %s",
                facility, severity, hostname, appName, timestamp, message);
    }
}
