package org.springblade.system.log;

import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import tech.powerjob.worker.log.OmsLogger;

/**
 *  组合日志，兼容 powerjob 日志
 * @author bfhuange
 * @date 2024/8/30
 */
@RequiredArgsConstructor
public class ComposeLogger implements OmsLogger {
    private final Logger log;
    private final OmsLogger omsLog;

    @Override
    public void debug(String s, Object... objects) {
        log.debug(s, objects);
        if (omsLog != null) {
            omsLog.debug(s, objects);
        }
    }

    @Override
    public void info(String s, Object... objects) {
        log.info(s, objects);
        if (omsLog != null) {
            omsLog.info(s, objects);
        }
    }

    @Override
    public void warn(String s, Object... objects) {
        log.warn(s, objects);
        if (omsLog != null) {
            omsLog.warn(s, objects);
        }
    }

    @Override
    public void error(String s, Object... objects) {
        log.error(s, objects);
        if (omsLog != null) {
            omsLog.error(s, objects);
        }
    }
}
