Migrate from slf4j to spring-jcl logger

Closes gh-819
This commit is contained in:
Stephane Nicoll 2019-02-08 13:16:23 +01:00
parent 9dc3cc65d1
commit b97b9f9350
5 changed files with 22 additions and 26 deletions

View File

@ -24,8 +24,8 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.spring.initializr.actuate.stat.StatsProperties.Elastic;
import io.spring.initializr.web.project.ProjectRequestEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.event.EventListener;
@ -44,8 +44,8 @@ import org.springframework.web.util.UriComponentsBuilder;
*/
public class ProjectGenerationStatPublisher {
private static final Logger log = LoggerFactory
.getLogger(ProjectGenerationStatPublisher.class);
private static final Log logger = LogFactory
.getLog(ProjectGenerationStatPublisher.class);
private final ProjectRequestDocumentFactory documentFactory;
@ -77,8 +77,8 @@ public class ProjectGenerationStatPublisher {
String json = null;
try {
ProjectRequestDocument document = this.documentFactory.createDocument(event);
if (log.isDebugEnabled()) {
log.debug("Publishing " + document);
if (logger.isDebugEnabled()) {
logger.debug("Publishing " + document);
}
json = toJson(document);
@ -91,7 +91,7 @@ public class ProjectGenerationStatPublisher {
});
}
catch (Exception ex) {
log.warn(String.format(
logger.warn(String.format(
"Failed to publish stat to index, document follows %n%n%s%n", json),
ex);
}

View File

@ -23,10 +23,6 @@
<artifactId>spring-boot</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>

View File

@ -21,8 +21,8 @@ import java.util.ArrayList;
import java.util.List;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.core.io.Resource;
import org.springframework.util.StreamUtils;
@ -188,8 +188,8 @@ public final class InitializrMetadataBuilder {
private static class ResourceInitializrMetadataCustomizer
implements InitializrMetadataCustomizer {
private static final Logger log = LoggerFactory.getLogger(
InitializrMetadataBuilder.ResourceInitializrMetadataCustomizer.class);
private static final Log logger = LogFactory
.getLog(ResourceInitializrMetadataCustomizer.class);
private static final Charset UTF_8 = Charset.forName("UTF-8");
@ -201,7 +201,7 @@ public final class InitializrMetadataBuilder {
@Override
public void customize(InitializrMetadata metadata) {
log.info("Loading initializr metadata from " + this.resource);
logger.info("Loading initializr metadata from " + this.resource);
try {
String content = StreamUtils.copyToString(this.resource.getInputStream(),
UTF_8);

View File

@ -42,13 +42,13 @@ import io.spring.initializr.web.mapper.InitializrMetadataVersion;
import io.spring.initializr.web.support.Agent;
import io.spring.initializr.web.support.Agent.AgentId;
import io.spring.initializr.web.support.CommandLineHelpGenerator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Tar;
import org.apache.tools.ant.taskdefs.Zip;
import org.apache.tools.ant.types.TarFileSet;
import org.apache.tools.ant.types.ZipFileSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.CacheControl;
import org.springframework.http.HttpHeaders;
@ -76,7 +76,7 @@ import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
@Controller
public class MainController extends AbstractInitializrController {
private static final Logger log = LoggerFactory.getLogger(MainController.class);
private static final Log logger = LogFactory.getLog(MainController.class);
/**
* HAL JSON content type.
@ -337,7 +337,7 @@ public class MainController extends AbstractInitializrController {
private ResponseEntity<byte[]> upload(File download, File dir, String fileName,
String contentType) throws IOException {
byte[] bytes = StreamUtils.copyToByteArray(new FileInputStream(download));
log.info("Uploading: {} ({} bytes)", download, bytes.length);
logger.info(String.format("Uploading: %s (%s bytes)", download, bytes.length));
ResponseEntity<byte[]> result = createResponseEntity(bytes, contentType,
fileName);
this.projectGenerationInvoker.cleanTempFiles(dir);

View File

@ -22,8 +22,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import io.spring.initializr.metadata.DefaultMetadataElement;
import io.spring.initializr.metadata.InitializrMetadata;
import io.spring.initializr.metadata.InitializrMetadataProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.util.StringUtils;
@ -37,8 +37,8 @@ import org.springframework.web.client.RestTemplate;
*/
public class DefaultInitializrMetadataProvider implements InitializrMetadataProvider {
private static final Logger log = LoggerFactory
.getLogger(DefaultInitializrMetadataProvider.class);
private static final Log logger = LogFactory
.getLog(DefaultInitializrMetadataProvider.class);
private final InitializrMetadata metadata;
@ -75,12 +75,12 @@ public class DefaultInitializrMetadataProvider implements InitializrMetadataProv
String url = this.metadata.getConfiguration().getEnv().getSpringBootMetadataUrl();
if (StringUtils.hasText(url)) {
try {
log.info("Fetching boot metadata from {}", url);
logger.info("Fetching boot metadata from " + url);
return new SpringBootMetadataReader(this.objectMapper, this.restTemplate,
url).getBootVersions();
}
catch (Exception ex) {
log.warn("Failed to fetch spring boot metadata", ex);
logger.warn("Failed to fetch spring boot metadata", ex);
}
}
return null;