mirror of
https://github.com/Threnklyn/MinecraftChat.git
synced 2026-05-19 04:43:28 +02:00
Added timestamps to console log
This commit is contained in:
@@ -1,13 +1,17 @@
|
|||||||
|
import moment from 'moment';
|
||||||
|
|
||||||
module.exports = (socket) => {
|
module.exports = (socket) => {
|
||||||
|
|
||||||
function onLogin() {
|
function onLogin() {
|
||||||
|
let timestamp = moment().format('MMM D h:mm:ss a');
|
||||||
|
|
||||||
socket.emit('buffer:success', `Successfully logged in as ${socket.mcbot.username} with entity id ${socket.mcbot.entity.id}`);
|
socket.emit('buffer:success', `Successfully logged in as ${socket.mcbot.username} with entity id ${socket.mcbot.entity.id}`);
|
||||||
socket.emit('bot:connect', {
|
socket.emit('bot:connect', {
|
||||||
host: socket.connectionParams.hostname,
|
host: socket.connectionParams.hostname,
|
||||||
port: socket.connectionParams.port,
|
port: socket.connectionParams.port,
|
||||||
username: socket.mcbot.username
|
username: socket.mcbot.username
|
||||||
});
|
});
|
||||||
console.log(`logged in > ${socket.connectionParams.hostname}:${socket.connectionParams.port} - Username: ${socket.mcbot.username}`);
|
console.log(`${timestamp}: logged in > ${socket.connectionParams.hostname}:${socket.connectionParams.port} - Username: ${socket.mcbot.username}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.mcbot.on('login', onLogin);
|
socket.mcbot.on('login', onLogin);
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
import mineflayer from 'mineflayer';
|
import mineflayer from 'mineflayer';
|
||||||
|
import moment from 'moment';
|
||||||
import events from '../../bot';
|
import events from '../../bot';
|
||||||
|
|
||||||
module.exports = (socket) => {
|
module.exports = (socket) => {
|
||||||
|
|
||||||
function onConnection(data) {
|
function onConnection(data) {
|
||||||
|
|
||||||
|
let timestamp = moment().format('MMM D h:mm:ss a');
|
||||||
|
|
||||||
// log activity to console
|
// log activity to console
|
||||||
console.log(`connecting > ${data.hostname}:${data.port} - ${data.username}`);
|
console.log(`${timestamp}: connecting > ${data.hostname}:${data.port} - ${data.username}`);
|
||||||
|
|
||||||
|
|
||||||
// inform user that connection is being made
|
// inform user that connection is being made
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
"grunt-nodemon": "^0.4.0",
|
"grunt-nodemon": "^0.4.0",
|
||||||
"gruntify-eslint": "^0.1.0",
|
"gruntify-eslint": "^0.1.0",
|
||||||
"mineflayer": "latest",
|
"mineflayer": "latest",
|
||||||
|
"moment": "^2.10.2",
|
||||||
"socket.io": "^1.3.5",
|
"socket.io": "^1.3.5",
|
||||||
"socket.io-redis": "^0.1.4"
|
"socket.io-redis": "^0.1.4"
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user