Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | "use strict"; |
michael@0 | 6 | |
michael@0 | 7 | this.EXPORTED_SYMBOLS = [ |
michael@0 | 8 | "getTestLogger", |
michael@0 | 9 | "initTestLogging", |
michael@0 | 10 | ]; |
michael@0 | 11 | |
michael@0 | 12 | const {utils: Cu} = Components; |
michael@0 | 13 | |
michael@0 | 14 | Cu.import("resource://gre/modules/Log.jsm"); |
michael@0 | 15 | |
michael@0 | 16 | this.initTestLogging = function initTestLogging(level) { |
michael@0 | 17 | function LogStats() { |
michael@0 | 18 | this.errorsLogged = 0; |
michael@0 | 19 | } |
michael@0 | 20 | LogStats.prototype = { |
michael@0 | 21 | format: function format(message) { |
michael@0 | 22 | if (message.level == Log.Level.Error) { |
michael@0 | 23 | this.errorsLogged += 1; |
michael@0 | 24 | } |
michael@0 | 25 | |
michael@0 | 26 | return message.loggerName + "\t" + message.levelDesc + "\t" + |
michael@0 | 27 | message.message + "\n"; |
michael@0 | 28 | } |
michael@0 | 29 | }; |
michael@0 | 30 | LogStats.prototype.__proto__ = new Log.Formatter(); |
michael@0 | 31 | |
michael@0 | 32 | let log = Log.repository.rootLogger; |
michael@0 | 33 | let logStats = new LogStats(); |
michael@0 | 34 | let appender = new Log.DumpAppender(logStats); |
michael@0 | 35 | |
michael@0 | 36 | if (typeof(level) == "undefined") { |
michael@0 | 37 | level = "Debug"; |
michael@0 | 38 | } |
michael@0 | 39 | getTestLogger().level = Log.Level[level]; |
michael@0 | 40 | Log.repository.getLogger("Services").level = Log.Level[level]; |
michael@0 | 41 | |
michael@0 | 42 | log.level = Log.Level.Trace; |
michael@0 | 43 | appender.level = Log.Level.Trace; |
michael@0 | 44 | // Overwrite any other appenders (e.g. from previous incarnations) |
michael@0 | 45 | log.ownAppenders = [appender]; |
michael@0 | 46 | log.updateAppenders(); |
michael@0 | 47 | |
michael@0 | 48 | return logStats; |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | this.getTestLogger = function getTestLogger(component) { |
michael@0 | 52 | return Log.repository.getLogger("Testing"); |
michael@0 | 53 | } |
michael@0 | 54 |