io.smilego.tenant.logging.schedule.ScheduleLog Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of multi-tenant-spring-boot-starter Show documentation
Show all versions of multi-tenant-spring-boot-starter Show documentation
A application used as an example on how to set up pushing
its components to the Central Repository.
The newest version!
package io.smilego.tenant.logging.schedule;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import io.smilego.tenant.TenantContext;
import io.smilego.tenant.logging.GeneralLog;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import lombok.extern.slf4j.Slf4j;
@EqualsAndHashCode(callSuper = true)
@Data
@SuperBuilder
@Slf4j
@ToString(callSuper = true)
public class ScheduleLog extends GeneralLog {
private String tenantId;
private String scheduleName;
public ScheduleLog(String traceId, String scheduleName) {
super();
setInitialTime(System.currentTimeMillis());
setTraceId(traceId);
setScheduleName(scheduleName);
setTenantId(TenantContext.getTenantId());
}
@Override
public void write() {
try {
setDurationMillis(System.currentTimeMillis() - getInitialTime());
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
String jsonLog = mapper.writeValueAsString(this);
log.info("{}", jsonLog);
}catch (Exception e){
log.error("Error during write log", e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy