mirror of
https://github.com/danbulant/flying-squid
synced 2026-06-18 22:11:07 +00:00
improve and fix logging
This commit is contained in:
parent
11640b8802
commit
9d1a3e3554
2 changed files with 3 additions and 9 deletions
|
|
@ -4,28 +4,23 @@ function inject(serv,player)
|
|||
{
|
||||
|
||||
player.on("connected",function(){
|
||||
console.log("[INFO]: " + player.username + ' connected');
|
||||
serv.log("[INFO]: " + player.username + ' connected');
|
||||
});
|
||||
|
||||
player.on("spawned",function(){
|
||||
console.log("[INFO]: position written, player spawning...");
|
||||
serv.log("[INFO]: position written, player spawning...");
|
||||
});
|
||||
|
||||
player.on("disconnected",function(){
|
||||
console.log("[INFO]: " + player.username + ' disconnected');
|
||||
serv.log("[INFO]: " + player.username + ' disconnected');
|
||||
});
|
||||
|
||||
player.on("error",function(error){
|
||||
console.log('[ERR] ' + error.stack);
|
||||
serv.log('[ERR]: Client: ' + error.stack);
|
||||
});
|
||||
|
||||
player.on("chat",function(message){
|
||||
message = '<' + player.username + '>' + ' ' + message;
|
||||
console.log("[INFO] " + message);
|
||||
serv.log("[INFO] " + message);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -8,18 +8,17 @@ module.exports=inject;
|
|||
function inject(serv,settings)
|
||||
{
|
||||
serv.on("error",function(error){
|
||||
console.log('[ERR] ', error.stack);
|
||||
log('[ERR]: Server:', error.stack);
|
||||
log('[ERR]: Server: '+error.stack);
|
||||
});
|
||||
|
||||
serv.on("listening",function(port){
|
||||
console.log('[INFO]: Server listening on port', port);
|
||||
log('[INFO]: Server listening on port', port);
|
||||
log('[INFO]: Server listening on port '+port);
|
||||
});
|
||||
|
||||
var logFile=path.join("logs",timeStarted + ".log");
|
||||
|
||||
function log(message) {
|
||||
console.log(message);
|
||||
if (!settings.logging) return;
|
||||
fs.appendFile(logFile, message + "\n",function(err){
|
||||
if (err) console.log(err);
|
||||
|
|
|
|||
Loading…
Reference in a new issue