commit b3201def305441341876a4cb8b78b23fe99b2339 Author: Ben Date: Tue Oct 16 16:44:56 2018 +0100 Initial commit diff --git a/config.js b/config.js new file mode 100644 index 0000000..7f77b5e --- /dev/null +++ b/config.js @@ -0,0 +1,14 @@ +const fs = require('fs'); + +module.exports = class Config { + constructor(path) { + this.path = path; + this.Config = { }; + } + + load() { + if (fs.existsSync(path)) { + + } + } +} diff --git a/index.js b/index.js new file mode 100644 index 0000000..22eedba --- /dev/null +++ b/index.js @@ -0,0 +1,20 @@ +const Logger = require('./logger'); +const Config = require('./config'); +// const Discord = require('discord.js'); +// const client = new Discord.Client(); + +Logger.init(); +let config = new Config('./config.json') +config.load(); + +// client.on('ready', () => { +// console.log(`Logged in as ${client.user.tag}!`); +// }); + +// client.on('message', msg => { +// if (msg.content === 'ping') { +// msg.reply('Pong!'); +// } +// }); + +// client.login('token'); \ No newline at end of file diff --git a/logger.js b/logger.js new file mode 100644 index 0000000..8069335 --- /dev/null +++ b/logger.js @@ -0,0 +1,83 @@ +const colours = require('colors/safe'); +const fs = require('fs'); + +let LogLevel = 1; +let logPath = 'logs.log'; + +module.exports = class Logger { + static init(path) { + if (path) logPath = path; + + if (!fs.existsSync(logPath)) { + fs.writeFileSync(logPath, ''); + } + fs.appendFileSync(logPath, '[SYSTEM STARTING UP] \n'); + } + + static SetLevel(level) { + LogLevel = level; + } + + static SetDialect(dialect) { + Dialect = dialect; + } + + static get VERBOSE_LOGS() {return 0;} + static get DEBUG_LOGS() {return 1;} + static get INFO_LOGS() {return 2;} + static get WARN_LOGS() {return 3;} + + static middleware(message) { + if (LogLevel > 0) return; + let d = new Date(); + fs.appendFileSync(logPath, `[${d.toLocaleString()}] [HTTP-MIDDLEWARE] ${message} \n`); + console.log('[' + d.toLocaleString() + '] [' + + colours.blue('HTTP-MIDDLEWARE') + '] ' + message); + } + + static debug(message) { + if (LogLevel > 1) return; + let d = new Date(); + fs.appendFileSync(logPath, `[${d.toLocaleString()}] [DEBUG] ${message} \n`); + console.log('[' + d.toLocaleString() + '] [' + + colours.cyan('DEBUG') + '] ' + message); + } + + static ready() { + let d = new Date(); + fs.appendFileSync(logPath, `[${d.toLocaleString()}] [READY] \n`); + console.log('[' + d.toLocaleString() + '] [' + + colours.rainbow('READY') + ']'); + } + + static info(message) { + if (LogLevel > 2) return; + let d = new Date(); + fs.appendFileSync(logPath, `[${d.toLocaleString()}] [INFO] ${message} \n`); + console.log('[' + d.toLocaleString() + '] [' + + colours.green('INFO') + '] ' + message); + } + + static warn(message) { + if (LogLevel > 3) return; + let d = new Date(); + fs.appendFileSync(logPath, `[${d.toLocaleString()}] [WARN] ${message} \n`); + console.log('[' + d.toLocaleString() + '] [' + + colours.yellow('WARN') + '] ' + message); + } + + static error(message) { + let d = new Date(); + fs.appendFileSync(logPath, `[${d.toLocaleString()}] [ERROR] ${message} \n`); + console.log('[' + d.toLocaleString() + '] [' + + colours.red('ERROR') + '] ' + message); + } + + static panic(message) { + let d = new Date(); + fs.appendFileSync(logPath, `[${d.toLocaleString()}] [PANIC] ${message} \n`); + console.log('[' + d.toLocaleString() + '] [' + + colours.red('PANIC') + '] ' + message); + process.exit(); + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..0c24346 --- /dev/null +++ b/package.json @@ -0,0 +1,11 @@ +{ + "name": "nullptr", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "MIT" +}