package kr.xit.core.biz.batch.listener;

import org.springframework.batch.core.ExitStatus;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.StepExecutionListener;
import org.springframework.batch.core.listener.StepExecutionListenerSupport;

import lombok.extern.slf4j.Slf4j;

/**
 * <pre>
 * description :  step 실행시 로그 출력
 *
 * packageName : kr.xit.core.biz.batch.listener
 * fileName    : CustomStepListener
 * author      : limju
 * date        : 2023-05-16
 * ======================================================================
 * 변경일         변경자        변경 내용
 * ----------------------------------------------------------------------
 * 2023-05-16    limju       최초 생성
 *
 * </pre>
 */
@Slf4j
public class CustomStepListener extends StepExecutionListenerSupport {

    @Override
    public void beforeStep(StepExecution stepExecution) {
        log.info("##### ↓ [{}] Step start", stepExecution.getStepName());
        //log.info("##### [{}-{}] Step is start", stepExecution.getJobExecution().getJobInstance().getJobName(), stepExecution.getStepName());
    }

    @Override
    public ExitStatus afterStep(StepExecution stepExecution) {
        log.info("##### ↑ [{}] Step end :: {}", stepExecution.getStepName(), stepExecution.getStatus());
        //log.info("##### [{}-{}] Step is completed {}", stepExecution.getJobExecution().getJobInstance().getJobName(), stepExecution.getStepName(), stepExecution.getStatus());
        return stepExecution.getExitStatus();
    }
}
