Skip to content

Commit

Permalink
seperate channel logs in different dir
Browse files Browse the repository at this point in the history
  • Loading branch information
maneulyori committed Feb 14, 2013
1 parent 9ff90db commit 1e9c2d9
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion modules/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,26 @@ function openLogStream(channel)
var date = new Date();
var timestamp = date.getFullYear().zeroPad(1000) + '-' + (date.getMonth()+1).zeroPad(10) + '-' + date.getDate().zeroPad(10);

var stats;
var dirIsNotExist = false;

try
{
stats = fs.lstatSync("logs/" + channel);
}
catch (e)
{
dirIsNotExist = true;
}

if(dirIsNotExist)
{
fs.mkdirSync("logs/" + channel, 0777);
}

channelLogStream[channel] = new Object();

channelLogStream[channel].stream = fs.createWriteStream("logs/" + channel + "-" + timestamp + ".log", { flags: "a", encoding: "UTF-8", mode: 0666});
channelLogStream[channel].stream = fs.createWriteStream("logs/" + channel + "/" + timestamp + ".log", { flags: "a", encoding: "UTF-8", mode: 0666});
channelLogStream[channel].date = date;

channelLogStream[channel].stream.write("Start logging at " + date + "\n");
Expand Down

0 comments on commit 1e9c2d9

Please sign in to comment.