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 {Preferences} = ChromeUtils.import("resource://gre/modules/Preferences.jsm");
|
|
|
|
const {Log: StdLog} = ChromeUtils.import("resource://gre/modules/Log.jsm");
|
|
|
|
|
|
|
|
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() {
|
|
|
|
return StdLog.Level[Preferences.get(LOG_LEVEL)] >= StdLog.Level.Info;
|
|
|
|
}
|
2019-02-12 17:44:54 +03:00
|
|
|
}
|