Minor changes

This commit is contained in:
Mattias Erming 2014-09-16 13:06:13 -07:00
parent 17f7ae7961
commit f3aee8f6cb
3 changed files with 15 additions and 12 deletions

View File

@ -1,7 +1,7 @@
{ {
"name": "shout", "name": "shout",
"description": "A web IRC client", "description": "A web IRC client",
"version": "0.31.0", "version": "0.31.1",
"author": "Mattias Erming", "author": "Mattias Erming",
"preferGlobal": true, "preferGlobal": true,
"bin": { "bin": {

View File

@ -1,5 +1,6 @@
var _ = require("lodash"); var _ = require("lodash");
var config = require("../config"); var config = require("../config");
var Chan = require("./models/chan");
var crypto = require("crypto"); var crypto = require("crypto");
var log = require("./log"); var log = require("./log");
var net = require("net"); var net = require("net");
@ -77,7 +78,16 @@ Client.prototype.emit = function(event, data) {
if (event == "msg") { if (event == "msg") {
var target = this.find(data.chan); var target = this.find(data.chan);
if (target) { if (target) {
log.write(this, target.network, target.chan, data.msg); var chan = target.chan.name;
if (target.chan.type == Chan.Type.LOBBY) {
chan = target.network.host;
}
log.write(
this.name,
target.network.host,
chan,
data.msg
);
} }
} }
} }

View File

@ -5,14 +5,8 @@ var moment = require("moment");
var Helper = require("./helper"); var Helper = require("./helper");
module.exports = { module.exports = {
write: function(client, network, chan, msg) { write: function(user, network, chan, msg) {
var path = Helper.resolveHomePath( var path = Helper.resolveHomePath("users", user, "logs", network);
"users",
client.name,
"logs",
network.host
);
try { try {
mkdirp.sync(path); mkdirp.sync(path);
} catch(e) { } catch(e) {
@ -23,7 +17,6 @@ module.exports = {
var tz = (config.logs || {}).timezone || "UTC+00:00"; var tz = (config.logs || {}).timezone || "UTC+00:00";
var time = moment().zone(tz).format(format); var time = moment().zone(tz).format(format);
var name = chan.type == "lobby" ? network.host : chan.name;
var line = "[" + time + "] "; var line = "[" + time + "] ";
if (msg.type == "message") { if (msg.type == "message") {
@ -41,7 +34,7 @@ module.exports = {
try { try {
fs.appendFile( fs.appendFile(
path + "/" + name + ".log", path + "/" + chan + ".log",
line + "\n" line + "\n"
); );
} catch(e) { } catch(e) {