[AB-xxx] minor logging updates

This commit is contained in:
Sheldan
2021-04-24 19:54:30 +02:00
parent 40eb516ddf
commit eb79522843
6 changed files with 22 additions and 1 deletions

View File

@@ -13,6 +13,7 @@ import dev.sheldan.abstracto.entertainment.config.EntertainmentFeatureDefinition
import dev.sheldan.abstracto.entertainment.config.EntertainmentModuleDefinition;
import dev.sheldan.abstracto.entertainment.exception.ReactTooManyReactionsException;
import dev.sheldan.abstracto.entertainment.service.EntertainmentService;
import lombok.extern.slf4j.Slf4j;
import net.dv8tion.jda.api.entities.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -21,6 +22,7 @@ import java.util.*;
import java.util.concurrent.CompletableFuture;
@Component
@Slf4j
public class React extends AbstractConditionableCommand {
@Autowired
@@ -38,6 +40,7 @@ public class React extends AbstractConditionableCommand {
List<String> reactionChars = entertainmentService.convertTextToEmojis(text);
int existingReactions = message.getReactions().size();
if(reactionChars.size() + existingReactions > Message.MAX_REACTIONS) {
log.error("Message has already {} reactions, {} would be added.", existingReactions, reactionChars.size());
throw new ReactTooManyReactionsException();
}
List<CompletableFuture<Void>> futures = new ArrayList<>();

View File

@@ -128,6 +128,7 @@ public class EntertainmentServiceBean implements EntertainmentService {
}
}
}
log.debug("Replaced {} combos.", replacedCombos.size());
Set<String> usedReplacements = new HashSet<>();
char[] split = text.toCharArray();
@@ -152,6 +153,7 @@ public class EntertainmentServiceBean implements EntertainmentService {
}
// reject any other character, as the ones we can deal with
if (!this.reactMapping.getSingle().containsKey(charAsString)) {
log.info("Cannot find mapping. Not replacing with emote.");
continue;
}
List<String> listToUse = this.reactMapping.getSingle().get(charAsString);
@@ -168,6 +170,7 @@ public class EntertainmentServiceBean implements EntertainmentService {
throw new ReactDuplicateCharacterException();
}
}
log.debug("We used {} replacements for a string of length {}.", usedReplacements.size(), text.length());
return result;
}
@@ -182,6 +185,8 @@ public class EntertainmentServiceBean implements EntertainmentService {
JsonReader reader = new JsonReader(new InputStreamReader(reactMappingSource.getInputStream()));
this.reactMapping = gson.fromJson(reader, ReactMapping.class);
this.reactMapping.populateKeys();
log.info("Loaded {} single replacement mappings.", this.reactMapping.getSingle().size());
log.info("Loaded {} combo replacements.", this.reactMapping.getCombination().size());
} catch (IOException e) {
log.error("Failed to load react bindings.", e);
}

View File

@@ -41,6 +41,7 @@ public class JoinLogger implements AsyncJoinListener {
.builder()
.member(listenerModel.getMember())
.build();
log.debug("Logging join event for user {} in server {}.", listenerModel.getMember().getIdLong(), listenerModel.getServerId());
MessageToSend messageToSend = templateService.renderEmbedTemplate(USER_JOIN_TEMPLATE, model, listenerModel.getServerId());
postTargetService.sendEmbedInPostTarget(messageToSend, LoggingPostTarget.JOIN_LOG, listenerModel.getServerId());
return DefaultListenerResult.PROCESSED;

View File

@@ -44,6 +44,7 @@ public class LeaveLogger implements AsyncLeaveListener {
.builder()
.user(listenerModel.getUser())
.build();
log.debug("Logging leave event for user {} in server {}.", listenerModel.getUser().getIdLong(), listenerModel.getServerId());
MessageToSend messageToSend = templateService.renderEmbedTemplate(USER_LEAVE_TEMPLATE, model, listenerModel.getServerId());
postTargetService.sendEmbedInPostTarget(messageToSend, LoggingPostTarget.LEAVE_LOG, listenerModel.getServerId());
return DefaultListenerResult.PROCESSED;

View File

@@ -73,7 +73,7 @@ public class MessageEditedListener implements AsyncMessageUpdatedListener {
List<CachedAttachment> removedAttachments = messageBefore.getAttachments().stream().filter(cachedAttachment ->
messageAfter.getAttachments().stream().noneMatch(attachment -> attachment.getIdLong() == cachedAttachment.getId())
).collect(Collectors.toList());
log.info("Logging deletion of {} attachments.", removedAttachments.size());
log.debug("Logging deletion of {} attachments.", removedAttachments.size());
for (int i = 0; i < removedAttachments.size(); i++) {
MessageDeletedAttachmentLog log = MessageDeletedAttachmentLog
.builder()