mirror of
https://gitee.com/dcren/initializr.git
synced 2025-09-18 17:48:14 +08:00
Migrate from slf4j to spring-jcl logger
Closes gh-819
This commit is contained in:
@@ -24,8 +24,8 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
|||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import io.spring.initializr.actuate.stat.StatsProperties.Elastic;
|
import io.spring.initializr.actuate.stat.StatsProperties.Elastic;
|
||||||
import io.spring.initializr.web.project.ProjectRequestEvent;
|
import io.spring.initializr.web.project.ProjectRequestEvent;
|
||||||
import org.slf4j.Logger;
|
import org.apache.commons.logging.Log;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||||
import org.springframework.context.event.EventListener;
|
import org.springframework.context.event.EventListener;
|
||||||
@@ -44,8 +44,8 @@ import org.springframework.web.util.UriComponentsBuilder;
|
|||||||
*/
|
*/
|
||||||
public class ProjectGenerationStatPublisher {
|
public class ProjectGenerationStatPublisher {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory
|
private static final Log logger = LogFactory
|
||||||
.getLogger(ProjectGenerationStatPublisher.class);
|
.getLog(ProjectGenerationStatPublisher.class);
|
||||||
|
|
||||||
private final ProjectRequestDocumentFactory documentFactory;
|
private final ProjectRequestDocumentFactory documentFactory;
|
||||||
|
|
||||||
@@ -77,8 +77,8 @@ public class ProjectGenerationStatPublisher {
|
|||||||
String json = null;
|
String json = null;
|
||||||
try {
|
try {
|
||||||
ProjectRequestDocument document = this.documentFactory.createDocument(event);
|
ProjectRequestDocument document = this.documentFactory.createDocument(event);
|
||||||
if (log.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
log.debug("Publishing " + document);
|
logger.debug("Publishing " + document);
|
||||||
}
|
}
|
||||||
json = toJson(document);
|
json = toJson(document);
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ public class ProjectGenerationStatPublisher {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
log.warn(String.format(
|
logger.warn(String.format(
|
||||||
"Failed to publish stat to index, document follows %n%n%s%n", json),
|
"Failed to publish stat to index, document follows %n%n%s%n", json),
|
||||||
ex);
|
ex);
|
||||||
}
|
}
|
||||||
|
@@ -23,10 +23,6 @@
|
|||||||
<artifactId>spring-boot</artifactId>
|
<artifactId>spring-boot</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.slf4j</groupId>
|
|
||||||
<artifactId>slf4j-api</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
@@ -21,8 +21,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.slf4j.Logger;
|
import org.apache.commons.logging.Log;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
import org.springframework.util.StreamUtils;
|
import org.springframework.util.StreamUtils;
|
||||||
@@ -188,8 +188,8 @@ public final class InitializrMetadataBuilder {
|
|||||||
private static class ResourceInitializrMetadataCustomizer
|
private static class ResourceInitializrMetadataCustomizer
|
||||||
implements InitializrMetadataCustomizer {
|
implements InitializrMetadataCustomizer {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(
|
private static final Log logger = LogFactory
|
||||||
InitializrMetadataBuilder.ResourceInitializrMetadataCustomizer.class);
|
.getLog(ResourceInitializrMetadataCustomizer.class);
|
||||||
|
|
||||||
private static final Charset UTF_8 = Charset.forName("UTF-8");
|
private static final Charset UTF_8 = Charset.forName("UTF-8");
|
||||||
|
|
||||||
@@ -201,7 +201,7 @@ public final class InitializrMetadataBuilder {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void customize(InitializrMetadata metadata) {
|
public void customize(InitializrMetadata metadata) {
|
||||||
log.info("Loading initializr metadata from " + this.resource);
|
logger.info("Loading initializr metadata from " + this.resource);
|
||||||
try {
|
try {
|
||||||
String content = StreamUtils.copyToString(this.resource.getInputStream(),
|
String content = StreamUtils.copyToString(this.resource.getInputStream(),
|
||||||
UTF_8);
|
UTF_8);
|
||||||
|
@@ -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;
|
||||||
import io.spring.initializr.web.support.Agent.AgentId;
|
import io.spring.initializr.web.support.Agent.AgentId;
|
||||||
import io.spring.initializr.web.support.CommandLineHelpGenerator;
|
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.Project;
|
||||||
import org.apache.tools.ant.taskdefs.Tar;
|
import org.apache.tools.ant.taskdefs.Tar;
|
||||||
import org.apache.tools.ant.taskdefs.Zip;
|
import org.apache.tools.ant.taskdefs.Zip;
|
||||||
import org.apache.tools.ant.types.TarFileSet;
|
import org.apache.tools.ant.types.TarFileSet;
|
||||||
import org.apache.tools.ant.types.ZipFileSet;
|
import org.apache.tools.ant.types.ZipFileSet;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import org.springframework.http.CacheControl;
|
import org.springframework.http.CacheControl;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
@@ -76,7 +76,7 @@ import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
|
|||||||
@Controller
|
@Controller
|
||||||
public class MainController extends AbstractInitializrController {
|
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.
|
* HAL JSON content type.
|
||||||
@@ -337,7 +337,7 @@ public class MainController extends AbstractInitializrController {
|
|||||||
private ResponseEntity<byte[]> upload(File download, File dir, String fileName,
|
private ResponseEntity<byte[]> upload(File download, File dir, String fileName,
|
||||||
String contentType) throws IOException {
|
String contentType) throws IOException {
|
||||||
byte[] bytes = StreamUtils.copyToByteArray(new FileInputStream(download));
|
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,
|
ResponseEntity<byte[]> result = createResponseEntity(bytes, contentType,
|
||||||
fileName);
|
fileName);
|
||||||
this.projectGenerationInvoker.cleanTempFiles(dir);
|
this.projectGenerationInvoker.cleanTempFiles(dir);
|
||||||
|
@@ -22,8 +22,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||||||
import io.spring.initializr.metadata.DefaultMetadataElement;
|
import io.spring.initializr.metadata.DefaultMetadataElement;
|
||||||
import io.spring.initializr.metadata.InitializrMetadata;
|
import io.spring.initializr.metadata.InitializrMetadata;
|
||||||
import io.spring.initializr.metadata.InitializrMetadataProvider;
|
import io.spring.initializr.metadata.InitializrMetadataProvider;
|
||||||
import org.slf4j.Logger;
|
import org.apache.commons.logging.Log;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
@@ -37,8 +37,8 @@ import org.springframework.web.client.RestTemplate;
|
|||||||
*/
|
*/
|
||||||
public class DefaultInitializrMetadataProvider implements InitializrMetadataProvider {
|
public class DefaultInitializrMetadataProvider implements InitializrMetadataProvider {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory
|
private static final Log logger = LogFactory
|
||||||
.getLogger(DefaultInitializrMetadataProvider.class);
|
.getLog(DefaultInitializrMetadataProvider.class);
|
||||||
|
|
||||||
private final InitializrMetadata metadata;
|
private final InitializrMetadata metadata;
|
||||||
|
|
||||||
@@ -75,12 +75,12 @@ public class DefaultInitializrMetadataProvider implements InitializrMetadataProv
|
|||||||
String url = this.metadata.getConfiguration().getEnv().getSpringBootMetadataUrl();
|
String url = this.metadata.getConfiguration().getEnv().getSpringBootMetadataUrl();
|
||||||
if (StringUtils.hasText(url)) {
|
if (StringUtils.hasText(url)) {
|
||||||
try {
|
try {
|
||||||
log.info("Fetching boot metadata from {}", url);
|
logger.info("Fetching boot metadata from " + url);
|
||||||
return new SpringBootMetadataReader(this.objectMapper, this.restTemplate,
|
return new SpringBootMetadataReader(this.objectMapper, this.restTemplate,
|
||||||
url).getBootVersions();
|
url).getBootVersions();
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
log.warn("Failed to fetch spring boot metadata", ex);
|
logger.warn("Failed to fetch spring boot metadata", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
Reference in New Issue
Block a user