package cn.reghao.tnb.content.app.util.rabbit;

import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.UnsynchronizedAppenderBase;
import cn.reghao.jutil.jdk.serializer.JsonConverter;
import org.springframework.amqp.rabbit.core.RabbitTemplate;

/**
 * @author reghao
 * @date 2025-07-18 09:54:51
 */
public class RabbitAppender extends UnsynchronizedAppenderBase<ILoggingEvent> {
    private final String app;
    private final String host;
    private final RabbitTemplate rabbitTemplate;

    public RabbitAppender(String app, String host, RabbitTemplate rabbitTemplate) {
        setName("rabbitAppender");
        this.app = app;
        this.host = host;
        this.rabbitTemplate = rabbitTemplate;
    }

    @Override
    public void start() {
        super.start();
    }

    @Override
    public void stop() {
        super.stop();
    }

    @Override
    protected void append(ILoggingEvent event) {
        String routingKey = "tnb.log.app";
        rabbitTemplate.convertAndSend(routingKey, "");
    }
}
