logger setup; log levels

v2
Kit Kasune 2 years ago
parent 36c5966dea
commit 47f113efc6
  1. 0
      bot.js
  2. 10
      src/db/connect.js
  3. 17
      src/util/log/getlevel.js
  4. 5
      src/util/log/levels.json
  5. 5
      src/util/log/log.js
  6. 0
      src/util/log/types.js

@ -0,0 +1,10 @@
module.exports = async client => {
const config = client.config;
try {
await mongoose.connect(`mongodb+srv://${config.database.user}:${config.database.password}@${config.database.cluster}.3jpp4.mongodb.net/test`, {
useFindAndModify: false, useNewUrlParser: true, dbName: 'Natsuki-Main', useUnifiedTopology: true, useCreateIndex: true
}).catch(() => {});
} catch (e) {
}
};

@ -0,0 +1,17 @@
const config = require('../../json/config.json');
const levels = require('./levels.json');
const validStrings = Object.keys(levels);
const getLevel = (level) => {
console.log(level)
if (typeof level === 'number') {
if (level <= 0) {return 0;}
if (level > 3) {return 3;}
return Math.floor(level);
} else {
const levelM = `${level}`.trim().toUpperCase();
return validStrings.includes(levelM) ? levels[levelM] : typeof config.log.defaultLevel === 'number' ? getLevel(config.log.defaultLevel) : 1;
}
};
module.exports = getLevel;

@ -0,0 +1,5 @@
{
"TOP": 0,
"STANDARD": 1,
"VERBOSE": 2
}

@ -0,0 +1,5 @@
module.exports = (message, level, source, color) => {
};
Loading…
Cancel
Save