From f4b95c5ca4cd253efc81f3680c2fd166a36bdecf Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Sun, 13 Jan 2013 12:20:49 +0100 Subject: [PATCH] Add log4js config setting --- bin/checkPad.js | 3 +-- bin/extractPadData.js | 5 ++--- bin/migrateDirtyDBtoMySQL.js | 1 + settings.json.template | 7 +++++++ src/node/server.js | 3 --- src/node/utils/Settings.js | 10 ++++++++++ 6 files changed, 21 insertions(+), 8 deletions(-) diff --git a/bin/checkPad.js b/bin/checkPad.js index a46c18140..a92f836ca 100644 --- a/bin/checkPad.js +++ b/bin/checkPad.js @@ -11,8 +11,7 @@ if(process.argv.length != 3) var padId = process.argv[2]; //initalize the database -var log4js = require("../src/node_modules/log4js"); -log4js.setGlobalLogLevel("INFO"); +var settings = require("../src/node/utils/Settings"); var async = require("../src/node_modules/async"); var db = require('../src/node/db/DB'); diff --git a/bin/extractPadData.js b/bin/extractPadData.js index f79b964af..ea00f953a 100644 --- a/bin/extractPadData.js +++ b/bin/extractPadData.js @@ -10,13 +10,11 @@ if(process.argv.length != 3) //get the padID var padId = process.argv[2]; -var db, dirty, padManager, pad; +var db, dirty, padManager, pad, settings; var neededDBValues = ["pad:"+padId]; var npm = require("../src/node_modules/npm"); var async = require("../src/node_modules/async"); -var log4js = require("../src/node_modules/log4js"); -log4js.setGlobalLogLevel("INFO"); async.series([ // load npm @@ -35,6 +33,7 @@ async.series([ }, // load modules function(callback) { + settings = require('../src/node/utils/Settings'); db = require('../src/node/db/DB'); dirty = require("../src/node_modules/ueberDB/node_modules/dirty")(padId + ".db"); }, diff --git a/bin/migrateDirtyDBtoMySQL.js b/bin/migrateDirtyDBtoMySQL.js index d0273de0d..b4913e762 100644 --- a/bin/migrateDirtyDBtoMySQL.js +++ b/bin/migrateDirtyDBtoMySQL.js @@ -2,6 +2,7 @@ require("ep_etherpad-lite/node_modules/npm").load({}, function(er,npm) { process.chdir(npm.root+'/..') + var settings = require("ep_etherpad-lite/node/utils/Settings"); var dirty = require("ep_etherpad-lite/node_modules/ueberDB/node_modules/dirty")('var/dirty.db'); var db = require("ep_etherpad-lite/node/db/DB"); diff --git a/settings.json.template b/settings.json.template index e37bc4509..04c097517 100644 --- a/settings.json.template +++ b/settings.json.template @@ -47,6 +47,13 @@ }, */ + //Logging configuration. See log4js documentation for further information + // https://github.com/nomiddlename/log4js-node + "logconfig" : + { "appenders": [ + { "type": "console" } + ] }, + //the default text of a pad "defaultPadText" : "Welcome to Etherpad Lite!\n\nThis pad text is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents!\n\nGet involved with Etherpad at http:\/\/etherpad.org\n", diff --git a/src/node/server.js b/src/node/server.js index 327fa166f..db75d7e37 100755 --- a/src/node/server.js +++ b/src/node/server.js @@ -25,7 +25,6 @@ var log4js = require('log4js') , async = require('async') ; -// set up logger log4js.replaceConsole(); var settings @@ -50,8 +49,6 @@ async.waterfall([ hooks = require("ep_etherpad-lite/static/js/pluginfw/hooks"); hooks.plugins = plugins; - //set loglevel - log4js.setGlobalLogLevel(settings.loglevel); callback(); }, diff --git a/src/node/utils/Settings.js b/src/node/utils/Settings.js index bed5a9a07..8435ab2c2 100644 --- a/src/node/utils/Settings.js +++ b/src/node/utils/Settings.js @@ -25,6 +25,7 @@ var path = require('path'); var argv = require('./Cli').argv; var npm = require("npm/lib/npm.js"); var vm = require('vm'); +var log4js = require("log4js"); /* Root path of the installation */ exports.root = path.normalize(path.join(npm.dir, "..")); @@ -106,6 +107,11 @@ exports.abiword = null; */ exports.loglevel = "INFO"; +/* +* log4js appender configuration +*/ +exports.logconfig = { appenders: [{ type: "console" }]}; + /* This setting is used if you need authentication and/or * authorization. Note: /admin always requires authentication, and * either authorization by a module, or a user with is_admin set */ @@ -173,6 +179,10 @@ exports.reloadSettings = function reloadSettings() { console.warn("Unknown Setting: '" + i + "'. This setting doesn't exist or it was removed"); } } + + log4js.configure(exports.logconfig);//Configure the logging appenders + log4js.setGlobalLogLevel(exports.loglevel);//set loglevel + log4js.replaceConsole(); if(exports.dbType === "dirty"){ console.warn("DirtyDB is used. This is fine for testing but not recommended for production.")