2019-01-29 18:18:42 +03: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-08 01:09:06 +03:00
|
|
|
const { Log: StdLog } = ChromeUtils.import("resource://gre/modules/Log.jsm");
|
2019-04-15 17:41:21 +03:00
|
|
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
2019-03-08 01:09:06 +03:00
|
|
|
|
|
|
|
const LOG_LEVEL = "remote.log.level";
|
|
|
|
|
2019-01-29 18:18:42 +03:00
|
|
|
/** E10s compatible wrapper for the standard logger from Log.jsm. */
|
2019-02-12 16:58:23 +03:00
|
|
|
class Log {
|
2019-01-29 18:18:42 +03:00
|
|
|
static get() {
|
|
|
|
const logger = StdLog.repository.getLogger("RemoteAgent");
|
|
|
|
if (logger.ownAppenders.length == 0) {
|
|
|
|
logger.addAppender(new StdLog.DumpAppender());
|
2019-03-08 01:09:06 +03:00
|
|
|
logger.manageLevelFromPref(LOG_LEVEL);
|
2019-01-29 18:18:42 +03:00
|
|
|
}
|
|
|
|
return logger;
|
|
|
|
}
|
2019-03-08 01:09:06 +03:00
|
|
|
|
|
|
|
static get verbose() {
|
2019-04-15 17:41:21 +03: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-08 01:09:06 +03:00
|
|
|
}
|
2019-02-12 17:44:54 +03:00
|
|
|
}
|