backend/src/main/java/com/magamochi/common/config/GitInfoLogger.java

31 lines
873 B
Java

package com.magamochi.common.config;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.boot.info.GitProperties;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class GitInfoLogger {
private final GitProperties gitProperties;
public GitInfoLogger(GitProperties gitProperties) {
this.gitProperties = gitProperties;
}
@EventListener(ApplicationStartedEvent.class)
public void logGitInfo() {
if (gitProperties != null) {
log.info(
"Git Info :: commit {} ({}) :: built at {}",
gitProperties.getShortCommitId(),
gitProperties.getBranch(),
gitProperties.getCommitTime());
} else {
log.info("Git Info :: not available");
}
}
}