mirror of
https://github.com/LamGC/ContentGrabbingJi.git
synced 2025-07-04 14:27:27 +00:00
[Change] log4j2.xml 调整日志输出到文件的限制;
[Change] 将内容较长的日志设为TRACE级别, 以减少日志占用; [CLear] 整理代码;
This commit is contained in:
@ -64,7 +64,7 @@ public class BotCode {
|
||||
|
||||
private String platformName;
|
||||
private String functionName;
|
||||
private Hashtable<String, String> parameter = new Hashtable<>();
|
||||
private final Hashtable<String, String> parameter = new Hashtable<>();
|
||||
|
||||
/**
|
||||
* 构造一个机器功能码
|
||||
|
@ -164,10 +164,10 @@ public final class CacheStoreCentral {
|
||||
ImageChecksum imageChecksum = getImageChecksum(illustId, pageIndex);
|
||||
if(imageChecksum != null) {
|
||||
try {
|
||||
log.debug("正在检查作品Id {} 第 {} 页图片文件 {} ...", illustId, pageIndex, imageFile.getName());
|
||||
log.trace("正在检查作品Id {} 第 {} 页图片文件 {} ...", illustId, pageIndex, imageFile.getName());
|
||||
if (ImageChecksum.checkFile(imageChecksum, Files.readAllBytes(imageFile.toPath()))) {
|
||||
imageCache.put(URLs.getResourceName(downloadLink), imageFile);
|
||||
log.debug("作品Id {} 第 {} 页缓存已补充.", illustId, pageIndex);
|
||||
log.trace("作品Id {} 第 {} 页缓存已补充.", illustId, pageIndex);
|
||||
return getImageToBotCode(imageFile, false).toString();
|
||||
} else {
|
||||
log.warn("图片文件 {} 校验失败, 重新下载图片...", imageFile.getName());
|
||||
@ -194,7 +194,7 @@ public final class CacheStoreCentral {
|
||||
return "(错误: 图片获取出错)";
|
||||
}
|
||||
} else {
|
||||
log.debug("图片 {} 缓存命中.", fileName);
|
||||
log.trace("图片 {} 缓存命中.", fileName);
|
||||
}
|
||||
|
||||
return getImageToBotCode(imageCache.get(fileName), false).toString();
|
||||
@ -240,7 +240,7 @@ public final class CacheStoreCentral {
|
||||
|
||||
if(Objects.isNull(illustInfoObj)) {
|
||||
illustInfoObj = illustInfoCache.getCache(illustIdStr).getAsJsonObject();
|
||||
log.debug("作品Id {} IllustInfo缓存命中.", illustId);
|
||||
log.trace("作品Id {} IllustInfo缓存命中.", illustId);
|
||||
}
|
||||
return illustInfoObj;
|
||||
}
|
||||
@ -259,7 +259,7 @@ public final class CacheStoreCentral {
|
||||
if (!illustPreLoadDataCache.exists(illustIdStr) || flushCache) {
|
||||
synchronized (illustIdStr) {
|
||||
if (!illustPreLoadDataCache.exists(illustIdStr) || flushCache) {
|
||||
log.debug("IllustId {} 缓存失效, 正在更新...", illustId);
|
||||
log.trace("IllustId {} 缓存失效, 正在更新...", illustId);
|
||||
JsonObject preLoadDataObj = BotGlobal.getGlobal().getPixivDownload()
|
||||
.getIllustPreLoadDataById(illustId)
|
||||
.getAsJsonObject("illust")
|
||||
@ -277,14 +277,14 @@ public final class CacheStoreCentral {
|
||||
|
||||
result = preLoadDataObj;
|
||||
illustPreLoadDataCache.update(illustIdStr, preLoadDataObj, expire);
|
||||
log.debug("作品Id {} preLoadData缓存已更新(有效时间: {})", illustId, expire);
|
||||
log.trace("作品Id {} preLoadData缓存已更新(有效时间: {})", illustId, expire);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(Objects.isNull(result)) {
|
||||
result = illustPreLoadDataCache.getCache(illustIdStr).getAsJsonObject();
|
||||
log.debug("作品Id {} PreLoadData缓存命中.", illustId);
|
||||
log.trace("作品Id {} PreLoadData缓存命中.", illustId);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -307,7 +307,7 @@ public final class CacheStoreCentral {
|
||||
|
||||
if(Objects.isNull(result)) {
|
||||
result = pagesCache.getCache(pagesSign);
|
||||
log.debug("作品Id {} Pages缓存命中.", illustId);
|
||||
log.trace("作品Id {} Pages缓存命中.", illustId);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -346,7 +346,7 @@ public final class CacheStoreCentral {
|
||||
if(!rankingCache.exists(requestSign) || flushCache) {
|
||||
synchronized(requestSign) {
|
||||
if(!rankingCache.exists(requestSign) || flushCache) {
|
||||
log.debug("Ranking缓存失效, 正在更新...(RequestSign: {})", requestSign);
|
||||
log.trace("Ranking缓存失效, 正在更新...(RequestSign: {})", requestSign);
|
||||
List<JsonObject> rankingResult = BotGlobal.getGlobal().getPixivDownload()
|
||||
.getRanking(contentType, mode, queryDate, 1, 500);
|
||||
long expireTime = 0;
|
||||
@ -356,16 +356,15 @@ public final class CacheStoreCentral {
|
||||
}
|
||||
result = new ArrayList<>(rankingResult).subList(start - 1, start + range - 1);
|
||||
rankingCache.update(requestSign, rankingResult, expireTime);
|
||||
log.debug("Ranking缓存更新完成.(RequestSign: {})", requestSign);
|
||||
log.trace("Ranking缓存更新完成.(RequestSign: {})", requestSign);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Objects.isNull(result)) {
|
||||
result = rankingCache.getCache(requestSign, start - 1, range);
|
||||
log.debug("RequestSign [{}] 缓存命中.", requestSign);
|
||||
log.trace("RequestSign [{}] 缓存命中.", requestSign);
|
||||
}
|
||||
log.debug("Result-Length: {}", result.size());
|
||||
return PixivDownload.getRanking(result, start - 1, range);
|
||||
}
|
||||
|
||||
@ -414,14 +413,14 @@ public final class CacheStoreCentral {
|
||||
for (String keyword : includeKeywords.split(";")) {
|
||||
searchBuilder.removeExcludeKeyword(keyword.trim());
|
||||
searchBuilder.addIncludeKeyword(keyword.trim());
|
||||
log.debug("已添加关键字: {}", keyword);
|
||||
log.trace("已添加关键字: {}", keyword);
|
||||
}
|
||||
}
|
||||
if (!Strings.isNullOrEmpty(excludeKeywords)) {
|
||||
for (String keyword : excludeKeywords.split(";")) {
|
||||
searchBuilder.removeIncludeKeyword(keyword.trim());
|
||||
searchBuilder.addExcludeKeyword(keyword.trim());
|
||||
log.debug("已添加排除关键字: {}", keyword);
|
||||
log.trace("已添加排除关键字: {}", keyword);
|
||||
}
|
||||
}
|
||||
|
||||
@ -433,7 +432,7 @@ public final class CacheStoreCentral {
|
||||
if(!searchBodyCache.exists(requestUrl)) {
|
||||
synchronized (requestUrl) {
|
||||
if (!searchBodyCache.exists(requestUrl)) {
|
||||
log.debug("searchBody缓存失效, 正在更新...");
|
||||
log.trace("searchBody缓存失效, 正在更新...");
|
||||
JsonObject jsonObject;
|
||||
HttpGet httpGetRequest = BotGlobal.getGlobal().getPixivDownload().
|
||||
createHttpGetRequest(requestUrl);
|
||||
@ -441,7 +440,7 @@ public final class CacheStoreCentral {
|
||||
getHttpClient().execute(httpGetRequest);
|
||||
|
||||
String responseBody = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
|
||||
log.debug("ResponseBody: {}", responseBody);
|
||||
log.trace("ResponseBody: {}", responseBody);
|
||||
jsonObject = BotGlobal.getGlobal().getGson().fromJson(responseBody, JsonObject.class);
|
||||
|
||||
if (jsonObject.get("error").getAsBoolean()) {
|
||||
@ -459,13 +458,13 @@ public final class CacheStoreCentral {
|
||||
}
|
||||
resultBody = jsonObject.getAsJsonObject().getAsJsonObject("body");
|
||||
searchBodyCache.update(requestUrl, jsonObject, expire);
|
||||
log.debug("searchBody缓存已更新(有效时间: {})", expire);
|
||||
log.trace("searchBody缓存已更新(有效时间: {})", expire);
|
||||
} else {
|
||||
log.debug("搜索缓存命中.");
|
||||
log.trace("搜索缓存命中.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.debug("搜索缓存命中.");
|
||||
log.trace("搜索缓存命中.");
|
||||
}
|
||||
|
||||
if(Objects.isNull(resultBody)) {
|
||||
|
@ -66,7 +66,7 @@ public class ImageCacheHandler implements EventHandler {
|
||||
throw requestException;
|
||||
}
|
||||
|
||||
log.debug("正在下载...(Content-Length: {}KB)", response.getEntity().getContentLength() / 1024);
|
||||
log.trace("正在下载...(Content-Length: {}KB)", response.getEntity().getContentLength() / 1024);
|
||||
ByteArrayOutputStream bufferOutputStream = new ByteArrayOutputStream();
|
||||
try(FileOutputStream fileOutputStream = new FileOutputStream(storeFile)) {
|
||||
Streams.copy(response.getEntity().getContent(), bufferOutputStream, false);
|
||||
|
@ -149,7 +149,7 @@ public class LocalHashCacheStore<T> implements CacheStore<T>, Cleanable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clean() throws Exception {
|
||||
public void clean() {
|
||||
Date currentDate = new Date();
|
||||
cache.forEach((key, value) -> {
|
||||
if(value.isExpire(currentDate)) {
|
||||
@ -160,8 +160,8 @@ public class LocalHashCacheStore<T> implements CacheStore<T>, Cleanable {
|
||||
|
||||
public static class CacheObject<T> implements Comparable<CacheObject<T>> {
|
||||
|
||||
private AtomicReference<T> value;
|
||||
private AtomicReference<Date> expire;
|
||||
private final AtomicReference<T> value;
|
||||
private final AtomicReference<Date> expire;
|
||||
|
||||
public CacheObject(T value, Date expire) {
|
||||
this.value = new AtomicReference<>(value);
|
||||
|
@ -105,8 +105,6 @@ public class BotEventHandler implements EventHandler {
|
||||
runnerConfig.addStringParameterParser(new DateParser(new SimpleDateFormat("yyyy-MM-dd")));
|
||||
runnerConfig.addStringParameterParser(new PagesQualityParser());
|
||||
|
||||
log.debug("DateParser添加情况: {}", runnerConfig.hasStringParameterParser(Date.class));
|
||||
|
||||
processRunner = new ArgumentsRunner(BotCommandProcess.class, runnerConfig);
|
||||
adminRunner = new ArgumentsRunner(BotAdminCommandProcess.class, runnerConfig);
|
||||
|
||||
|
@ -6,9 +6,9 @@ import net.lz1998.cq.robot.CoolQ;
|
||||
|
||||
public class SpringCQMessageSender implements MessageSender {
|
||||
|
||||
private CoolQ coolQ;
|
||||
private MessageSource source;
|
||||
private long target;
|
||||
private final CoolQ coolQ;
|
||||
private final MessageSource source;
|
||||
private final long target;
|
||||
|
||||
public SpringCQMessageSender(CoolQ coolQ, MessageSource source, long target) {
|
||||
this.coolQ = coolQ;
|
||||
|
@ -151,7 +151,7 @@ public class MiraiMessageSender implements MessageSender {
|
||||
synchronized (imageName) {
|
||||
if(!imageIdCache.exists(imageName) ||
|
||||
Strings.nullToEmpty(code.getParameter("updateCache")) .equalsIgnoreCase("true")) {
|
||||
log.debug("imageName [{}] 缓存失效或强制更新, 正在更新缓存...", imageName);
|
||||
log.trace("imageName [{}] 缓存失效或强制更新, 正在更新缓存...", imageName);
|
||||
image = uploadImage0(new File(absolutePath));
|
||||
String cacheExpireAt;
|
||||
long expireTime = 864000000; // 10d
|
||||
@ -163,13 +163,13 @@ public class MiraiMessageSender implements MessageSender {
|
||||
}
|
||||
}
|
||||
imageIdCache.update(imageName, image.getImageId(), expireTime);
|
||||
log.debug("imageName [{}] 缓存更新完成.(有效时间: {})", imageName, expireTime);
|
||||
log.trace("imageName [{}] 缓存更新完成.(有效时间: {})", imageName, expireTime);
|
||||
} else {
|
||||
log.debug("ImageName: [{}] 缓存命中.", imageName);
|
||||
log.trace("ImageName: [{}] 缓存命中.", imageName);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.debug("ImageName: [{}] 缓存命中.", imageName);
|
||||
log.trace("ImageName: [{}] 缓存命中.", imageName);
|
||||
}
|
||||
|
||||
if(image == null) {
|
||||
|
Reference in New Issue
Block a user