Skip to content

Commit

Permalink
Minor logging updates
Browse files Browse the repository at this point in the history
  • Loading branch information
slmnio committed Dec 30, 2022
1 parent d357557 commit d0def6f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
7 changes: 5 additions & 2 deletions server/src/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,11 @@ async function set(id, data, options) {
if (oldData && (data.modified !== oldData.modified)) {
let [oldDate, newDate] = [oldData.modified, data.modified].map(x => new Date(x));
if (newDate.getTime() < oldDate.getTime()) {
console.log(`[old] id=${id} \n old=${oldDate.toLocaleString()} \n new=${newDate.toLocaleString()}`);
console.warn(" old data is newer, keeping it!");
if (oldDate.getTime() - newDate.getTime() > 3000) {
// only send a log if it's over 3 seconds
console.log(`[old] id=${id} \n old=${oldDate.toLocaleString()} \n new=${newDate.toLocaleString()}`);
console.warn(" old data is newer, keeping it!");
}
// console.log("old data:");
// console.log(oldData);
// console.log("new data:");
Expand Down
1 change: 1 addition & 0 deletions server/src/discord/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ module.exports = ({ app, router, cors, Cache, io }) => {
});
}
if (!user.airtable) {
console.log(`[Auth] No SLMN.GG profile for ${user.discord.id} ${user.discord.username}#${user.discord.discriminator}`);
return res.send({
error: true,
message: "No SLMN.GG profile found",
Expand Down
6 changes: 5 additions & 1 deletion server/src/discord/slmngg-log.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ async function log(text) {
if (!client) return;
let channel = await getChannel();
if (!channel) return;
return channel.send(text);
try {
return channel.send(text);
} catch (e) {
console.error("[Log:failed]", e);
}
}

module.exports = {
Expand Down

0 comments on commit d0def6f

Please sign in to comment.