Browse Source

git subrepo pull (merge) discord-bot-core

subrepo:
  subdir:   "discord-bot-core"
  merged:   "5fd4a43"
upstream:
  origin:   "git@github.com:benji7425/discord-bot-core.git"
  branch:   "master"
  commit:   "5fd4a43"
git-subrepo:
  version:  "0.3.1"
  origin:   "???"
  commit:   "???"
master
benji7425 4 years ago
parent
commit
3cfddd1f58
  1. 4
      discord-bot-core/.gitrepo
  2. 2
      discord-bot-core/Client.js
  3. 30
      discord-bot-core/Util.js

4
discord-bot-core/.gitrepo

@ -6,7 +6,7 @@
[subrepo]
remote = git@github.com:benji7425/discord-bot-core.git
branch = master
commit = 8efb033b8f7f421677f7ddb1aa3cc7801202bd54
parent = ba6caa6be5cd775f794246736e1395ed7fa9f979
commit = 5fd4a4323c96a7c75fef5cbe80c36ab02cf83c57
parent = 68f565c65c702462b84b0c2abc22711db92c3821
method = merge
cmdver = 0.3.1

2
discord-bot-core/Client.js

@ -56,7 +56,7 @@ module.exports = class Client extends Discord.Client {
onDebug(info) {
if (!InternalConfig.debugIgnores.some(x => info.startsWith(x)))
CoreUtil.dateLog(info);
CoreUtil.dateDebug(info);
}
onUnhandledException(client, err) {

30
discord-bot-core/Util.js

@ -1,7 +1,8 @@
const Console = require("console");
const SimpleFileWriter = require("simple-file-writer");
const logWriter = new SimpleFileWriter("./log");
const logWriter = new SimpleFileWriter("./console.log");
const debugLogWriter = new SimpleFileWriter("./debug.log");
/**
* Returns a promise that the user will answer
@ -27,23 +28,40 @@ function ask(client, textChannel, member, question) {
}
function dateLog(...args) {
args = formatArgs(args);
Console.log.apply(this, args);
logWriter.write(args.join("") + "\n");
doDateLog(Console.log, logWriter, args);
}
function dateError(...args) {
doDateLog(Console.error, logWriter, args);
}
function dateDebug(...args) {
doDateLog(null, null, args);
}
function doDateLog(consoleMethod, fileWriter, args) {
args = formatArgs(args);
Console.error.apply(this, args);
logWriter.write(args.join("") + "\n");
if (consoleMethod !== null)
consoleMethod.apply(this, args);
if (fileWriter !== null)
fileWriter.write(formatArgsForFile(args));
debugLogWriter.write(formatArgsForFile(args));
}
function formatArgs(args) {
return ["[", new Date().toUTCString(), "] "].concat(args);
}
function formatArgsForFile(args) {
return args.join("") + "\n";
}
module.exports = {
dateError,
dateLog,
dateDebug,
ask
};
Loading…
Cancel
Save