2019-01-29 15:18:42 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var EXPORTED_SYMBOLS = ["Log"];
|
|
|
|
|
2019-03-07 22:09:06 +00:00
|
|
|
const { Log: StdLog } = ChromeUtils.import("resource://gre/modules/Log.jsm");
|
2019-04-15 14:41:21 +00:00
|
|
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
2019-03-07 22:09:06 +00:00
|
|
|
|
|
|
|
const LOG_LEVEL = "remote.log.level";
|
|
|
|
|
2019-01-29 15:18:42 +00:00
|
|
|
/** E10s compatible wrapper for the standard logger from Log.jsm. */
|
2019-02-12 13:58:23 +00:00
|
|
|
class Log {
|
2019-01-29 15:18:42 +00:00
|
|
|
static get() {
|
|
|
|
const logger = StdLog.repository.getLogger("RemoteAgent");
|
|
|
|
if (logger.ownAppenders.length == 0) {
|
|
|
|
logger.addAppender(new StdLog.DumpAppender());
|
2019-03-07 22:09:06 +00:00
|
|
|
logger.manageLevelFromPref(LOG_LEVEL);
|
2019-01-29 15:18:42 +00:00
|
|
|
}
|
|
|
|
return logger;
|
|
|
|
}
|
2019-03-07 22:09:06 +00:00
|
|
|
|
|
|
|
static get verbose() {
|
2019-04-15 14:41:21 +00:00
|
|
|
// we can't use Preferences.jsm before first paint,
|
|
|
|
// see ../browser/base/content/test/performance/browser_startup.js
|
|
|
|
const level = Services.prefs.getStringPref(LOG_LEVEL, "Info");
|
|
|
|
return StdLog.Level[level] >= StdLog.Level.Info;
|
2019-03-07 22:09:06 +00:00
|
|
|
}
|
2019-02-12 14:44:54 +00:00
|
|
|
}
|