-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from Adamant-im/dev
v5.7.0
- Loading branch information
Showing
34 changed files
with
2,751 additions
and
2,062 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/trade/settings | ||
/trade/tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
function time() { | ||
return formatDate(Date.now()).hh_mm_ss; | ||
} | ||
|
||
function date() { | ||
return formatDate(Date.now()).YYYY_MM_DD; | ||
} | ||
|
||
function fullTime() { | ||
return date() + ' ' + time(); | ||
} | ||
|
||
/** | ||
* Formats unix timestamp to string | ||
* @param {number} timestamp Timestamp to format | ||
* @return {object} Contains different formatted strings | ||
*/ | ||
function formatDate(timestamp) { | ||
if (!timestamp) return false; | ||
const formattedDate = {}; | ||
const dateObject = new Date(timestamp); | ||
formattedDate.year = dateObject.getFullYear(); | ||
formattedDate.month = ('0' + (dateObject.getMonth() + 1)).slice(-2); | ||
formattedDate.date = ('0' + dateObject.getDate()).slice(-2); | ||
formattedDate.hours = ('0' + dateObject.getHours()).slice(-2); | ||
formattedDate.minutes = ('0' + dateObject.getMinutes()).slice(-2); | ||
formattedDate.seconds = ('0' + dateObject.getSeconds()).slice(-2); | ||
formattedDate.YYYY_MM_DD = formattedDate.year + '-' + formattedDate.month + '-' + formattedDate.date; | ||
formattedDate.YYYY_MM_DD_hh_mm = formattedDate.year + '-' + formattedDate.month + '-' + formattedDate.date + ' ' + formattedDate.hours + ':' + formattedDate.minutes; | ||
formattedDate.hh_mm_ss = formattedDate.hours + ':' + formattedDate.minutes + ':' + formattedDate.seconds; | ||
return formattedDate; | ||
} | ||
|
||
module.exports = { | ||
time, | ||
date, | ||
fullTime, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,7 +72,7 @@ module.exports = (db) => { | |
return this._id; | ||
} | ||
} | ||
}; | ||
} | ||
|
||
return Model; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,48 @@ | ||
const config = require('../modules/configReader'); | ||
const dateTime = require('./dateTime'); | ||
|
||
const fs = require('fs'); | ||
if (!fs.existsSync('./logs')) { | ||
fs.mkdirSync('./logs'); | ||
} | ||
|
||
const infoStr = fs.createWriteStream('./logs/' + date() + '.log', { | ||
const infoStr = fs.createWriteStream('./logs/' + dateTime.date() + '.log', { | ||
flags: 'a', | ||
}); | ||
|
||
infoStr.write(`\n\n[The bot started] _________________${fullTime()}_________________\n`); | ||
infoStr.write(`\n\n[The bot started] _________________${dateTime.fullTime()}_________________\n`); | ||
|
||
module.exports = { | ||
error(str) { | ||
if (['error', 'warn', 'info', 'log'].includes(config.log_level)) { | ||
infoStr.write(`\n ` + 'error|' + fullTime() + '|' + str); | ||
console.log('\x1b[31m', 'error|' + fullTime(), '\x1b[0m', str); | ||
if (!process.env.CLI_MODE_ENABLED) { | ||
console.log('\x1b[31m', 'error|' + dateTime.fullTime(), '\x1b[0m', str); | ||
} | ||
infoStr.write('\n ' + 'error|' + dateTime.fullTime() + '|' + str); | ||
} | ||
}, | ||
warn(str) { | ||
if (['warn', 'info', 'log'].includes(config.log_level)) { | ||
console.log('\x1b[33m', 'warn|' + fullTime(), '\x1b[0m', str); | ||
infoStr.write(`\n ` + 'warn|' + fullTime() + '|' + str); | ||
if (!process.env.CLI_MODE_ENABLED) { | ||
console.log('\x1b[33m', 'warn|' + dateTime.fullTime(), '\x1b[0m', str); | ||
} | ||
infoStr.write('\n ' + 'warn|' + dateTime.fullTime() + '|' + str); | ||
} | ||
}, | ||
info(str) { | ||
if (['info', 'log'].includes(config.log_level)) { | ||
console.log('\x1b[32m', 'info|' + fullTime(), '\x1b[0m', str); | ||
infoStr.write(`\n ` + 'info|' + fullTime() + '|' + str); | ||
if (!process.env.CLI_MODE_ENABLED) { | ||
console.log('\x1b[32m', 'info|' + dateTime.fullTime(), '\x1b[0m', str); | ||
} | ||
infoStr.write('\n ' + 'info|' + dateTime.fullTime() + '|' + str); | ||
} | ||
}, | ||
log(str) { | ||
if (['log'].includes(config.log_level)) { | ||
console.log('\x1b[34m', 'log|' + fullTime(), '\x1b[0m', str); | ||
infoStr.write(`\n ` + 'log|[' + fullTime() + '|' + str); | ||
if (!process.env.CLI_MODE_ENABLED) { | ||
console.log('\x1b[34m', 'log|' + dateTime.fullTime(), '\x1b[0m', str); | ||
} | ||
infoStr.write('\n ' + 'log|[' + dateTime.fullTime() + '|' + str); | ||
} | ||
}, | ||
}; | ||
|
||
function time() { | ||
return formatDate(Date.now()).hh_mm_ss; | ||
} | ||
|
||
function date() { | ||
return formatDate(Date.now()).YYYY_MM_DD; | ||
} | ||
|
||
function fullTime() { | ||
return date() + ' ' + time(); | ||
} | ||
|
||
/** | ||
* Formats unix timestamp to string | ||
* @param {number} timestamp Timestamp to format | ||
* @return {object} Contains different formatted strings | ||
*/ | ||
function formatDate(timestamp) { | ||
if (!timestamp) return false; | ||
const formattedDate = {}; | ||
const dateObject = new Date(timestamp); | ||
formattedDate.year = dateObject.getFullYear(); | ||
formattedDate.month = ('0' + (dateObject.getMonth() + 1)).slice(-2); | ||
formattedDate.date = ('0' + dateObject.getDate()).slice(-2); | ||
formattedDate.hours = ('0' + dateObject.getHours()).slice(-2); | ||
formattedDate.minutes = ('0' + dateObject.getMinutes()).slice(-2); | ||
formattedDate.seconds = ('0' + dateObject.getSeconds()).slice(-2); | ||
formattedDate.YYYY_MM_DD = formattedDate.year + '-' + formattedDate.month + '-' + formattedDate.date; | ||
formattedDate.YYYY_MM_DD_hh_mm = formattedDate.year + '-' + formattedDate.month + '-' + formattedDate.date + ' ' + formattedDate.hours + ':' + formattedDate.minutes; | ||
formattedDate.hh_mm_ss = formattedDate.hours + ':' + formattedDate.minutes + ':' + formattedDate.seconds; | ||
return formattedDate; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.