mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Merged changes
This commit is contained in:
commit
e9a097b252
@ -84,7 +84,15 @@ let Log4Moz = {
|
|||||||
delete Log4Moz.Service;
|
delete Log4Moz.Service;
|
||||||
Log4Moz.Service = new Log4MozService();
|
Log4Moz.Service = new Log4MozService();
|
||||||
return Log4Moz.Service;
|
return Log4Moz.Service;
|
||||||
}
|
},
|
||||||
|
|
||||||
|
get Formatter() { return Formatter; },
|
||||||
|
get BasicFormatter() { return BasicFormatter; },
|
||||||
|
get Appender() { return Appender; },
|
||||||
|
get DumpAppender() { return DumpAppender; },
|
||||||
|
get ConsoleAppender() { return ConsoleAppender; },
|
||||||
|
get FileAppender() { return FileAppender; },
|
||||||
|
get RotatingFileAppender() { return RotatingFileAppender; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -412,6 +420,12 @@ FileAppender.prototype.__proto__ = new Appender();
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function RotatingFileAppender(file, formatter, maxSize, maxBackups) {
|
function RotatingFileAppender(file, formatter, maxSize, maxBackups) {
|
||||||
|
if (maxSize === undefined)
|
||||||
|
maxSize = ONE_MEGABYTE * 2;
|
||||||
|
|
||||||
|
if (maxBackups === undefined)
|
||||||
|
maxBackups = 0;
|
||||||
|
|
||||||
this._name = "RotatingFileAppender";
|
this._name = "RotatingFileAppender";
|
||||||
this._file = file; // nsIFile
|
this._file = file; // nsIFile
|
||||||
this._formatter = formatter;
|
this._formatter = formatter;
|
||||||
@ -471,40 +485,5 @@ Log4MozService.prototype = {
|
|||||||
|
|
||||||
getLogger: function LogSvc_getLogger(name) {
|
getLogger: function LogSvc_getLogger(name) {
|
||||||
return this._repository.getLogger(name);
|
return this._repository.getLogger(name);
|
||||||
},
|
|
||||||
|
|
||||||
newAppender: function LogSvc_newAppender(kind, formatter) {
|
|
||||||
switch (kind) {
|
|
||||||
case "dump":
|
|
||||||
return new DumpAppender(formatter);
|
|
||||||
case "console":
|
|
||||||
return new ConsoleAppender(formatter);
|
|
||||||
default:
|
|
||||||
dump("log4moz: unknown appender kind: " + kind);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
newFileAppender: function LogSvc_newAppender(kind, file, formatter) {
|
|
||||||
switch (kind) {
|
|
||||||
case "file":
|
|
||||||
return new FileAppender(file, formatter);
|
|
||||||
case "rotating":
|
|
||||||
// FIXME: hardcoded constants
|
|
||||||
return new RotatingFileAppender(file, formatter, ONE_MEGABYTE * 2, 0);
|
|
||||||
default:
|
|
||||||
dump("log4moz: unknown appender kind: " + kind);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
newFormatter: function LogSvc_newFormatter(kind) {
|
|
||||||
switch (kind) {
|
|
||||||
case "basic":
|
|
||||||
return new BasicFormatter();
|
|
||||||
default:
|
|
||||||
dump("log4moz: unknown formatter kind: " + kind);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -227,15 +227,15 @@ WeaveSvc.prototype = {
|
|||||||
this._log.level =
|
this._log.level =
|
||||||
Log4Moz.Level[Utils.prefs.getCharPref("log.logger.service.main")];
|
Log4Moz.Level[Utils.prefs.getCharPref("log.logger.service.main")];
|
||||||
|
|
||||||
let formatter = Log4Moz.Service.newFormatter("basic");
|
let formatter = new Log4Moz.BasicFormatter();
|
||||||
let root = Log4Moz.Service.rootLogger;
|
let root = Log4Moz.Service.rootLogger;
|
||||||
root.level = Log4Moz.Level[Utils.prefs.getCharPref("log.rootLogger")];
|
root.level = Log4Moz.Level[Utils.prefs.getCharPref("log.rootLogger")];
|
||||||
|
|
||||||
let capp = Log4Moz.Service.newAppender("console", formatter);
|
let capp = new Log4Moz.ConsoleAppender(formatter);
|
||||||
capp.level = Log4Moz.Level[Utils.prefs.getCharPref("log.appender.console")];
|
capp.level = Log4Moz.Level[Utils.prefs.getCharPref("log.appender.console")];
|
||||||
root.addAppender(capp);
|
root.addAppender(capp);
|
||||||
|
|
||||||
let dapp = Log4Moz.Service.newAppender("dump", formatter);
|
let dapp = new Log4Moz.DumpAppender(formatter);
|
||||||
dapp.level = Log4Moz.Level[Utils.prefs.getCharPref("log.appender.dump")];
|
dapp.level = Log4Moz.Level[Utils.prefs.getCharPref("log.appender.dump")];
|
||||||
root.addAppender(dapp);
|
root.addAppender(dapp);
|
||||||
|
|
||||||
@ -252,10 +252,10 @@ WeaveSvc.prototype = {
|
|||||||
if (!verbose.exists())
|
if (!verbose.exists())
|
||||||
verbose.create(verbose.NORMAL_FILE_TYPE, PERMS_FILE);
|
verbose.create(verbose.NORMAL_FILE_TYPE, PERMS_FILE);
|
||||||
|
|
||||||
this._briefApp = Log4Moz.Service.newFileAppender("rotating", brief, formatter);
|
this._briefApp = new Log4Moz.RotatingFileAppender(brief, formatter);
|
||||||
this._briefApp.level = Log4Moz.Level[Utils.prefs.getCharPref("log.appender.briefLog")];
|
this._briefApp.level = Log4Moz.Level[Utils.prefs.getCharPref("log.appender.briefLog")];
|
||||||
root.addAppender(this._briefApp);
|
root.addAppender(this._briefApp);
|
||||||
this._debugApp = Log4Moz.Service.newFileAppender("rotating", verbose, formatter);
|
this._debugApp = new Log4Moz.RotatingFileAppender(verbose, formatter);
|
||||||
this._debugApp.level = Log4Moz.Level[Utils.prefs.getCharPref("log.appender.debugLog")];
|
this._debugApp.level = Log4Moz.Level[Utils.prefs.getCharPref("log.appender.debugLog")];
|
||||||
root.addAppender(this._debugApp);
|
root.addAppender(this._debugApp);
|
||||||
},
|
},
|
||||||
|
27
services/sync/tests/unit/test_log4moz.js
Normal file
27
services/sync/tests/unit/test_log4moz.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
Components.utils.import("resource://weave/log4moz.js");
|
||||||
|
|
||||||
|
function MockAppender(formatter) {
|
||||||
|
this._formatter = formatter;
|
||||||
|
this.messages = [];
|
||||||
|
}
|
||||||
|
MockAppender.prototype = {
|
||||||
|
doAppend: function DApp_doAppend(message) {
|
||||||
|
this.messages.push(message);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
MockAppender.prototype.__proto__ = new Log4Moz.Appender();
|
||||||
|
|
||||||
|
function run_test() {
|
||||||
|
var log = Log4Moz.Service.rootLogger;
|
||||||
|
var appender = new MockAppender(new Log4Moz.BasicFormatter());
|
||||||
|
|
||||||
|
log.level = Log4Moz.Level.Debug;
|
||||||
|
appender.level = Log4Moz.Level.Info;
|
||||||
|
log.addAppender(appender);
|
||||||
|
log.info("info test");
|
||||||
|
log.debug("this should be logged but not appended.");
|
||||||
|
|
||||||
|
do_check_eq(appender.messages.length, 1);
|
||||||
|
do_check_true(appender.messages[0].indexOf("info test") > 0);
|
||||||
|
do_check_true(appender.messages[0].indexOf("INFO") > 0);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user