From f65ffdff1ecbe6adbdb84639b5c7827ff19114b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Astori?= Date: Sun, 15 May 2016 17:13:51 -0400 Subject: [PATCH] Centralize the logs path in the Helper --- src/helper.js | 5 +++++ src/userLog.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/helper.js b/src/helper.js index ac323d90..b6d11cad 100644 --- a/src/helper.js +++ b/src/helper.js @@ -5,6 +5,7 @@ var Helper = { expandHome: expandHome, getConfig: getConfig, getUserConfigPath: getUserConfigPath, + getUserLogsPath: getUserLogsPath, setHome: setHome, }; @@ -20,6 +21,10 @@ function getUserConfigPath(name) { return path.join(this.USERS_PATH, name + ".json"); } +function getUserLogsPath(name, network) { + return path.join(this.HOME, "logs", name, network); +} + function getConfig() { return require(this.CONFIG_PATH); } diff --git a/src/userLog.js b/src/userLog.js index a559b190..c2805dc6 100644 --- a/src/userLog.js +++ b/src/userLog.js @@ -5,7 +5,7 @@ var Helper = require("./helper"); module.exports.write = function(user, network, chan, msg) { try { - var path = require("path").join(Helper.HOME, "logs", user, network); + var path = Helper.getUserLogsPath(user, network); mkdirp.sync(path); } catch (e) { log.error("Unabled to create logs directory", e);