B2G/gecko/services/healthreport/HealthReportService.js
/**
   * The HealthReporter instance associated with this service.
   */
The HealthReporter instance associated with this service.
The HealthReporter instance associated with this service .
get reporter() {
    if (!this.prefs.get("serviceEnabled", true)) {
      return null;
    }
    if (this._reporter) {
      return this._reporter;
    }
    let ns = {};
    Cu.import("resource://services-common/log4moz.js", ns);
    Cu.import("resource://gre/modules/services/healthreport/healthreporter.jsm", ns);
    const LOGGERS = [
      "Metrics",
      "Services.HealthReport",
      "Services.Metrics",
      "Services.BagheeraClient",
    ];
    let prefs = new Preferences(BRANCH + "logging.");
    if (prefs.get("consoleEnabled", true)) {
      let level = prefs.get("consoleLevel", "Warn");
      let appender = new ns.Log4Moz.ConsoleAppender();
      appender.level = ns.Log4Moz.Level[level] || ns.Log4Moz.Level.Warn;
      for (let name of LOGGERS) {
        let logger = ns.Log4Moz.repository.getLogger(name);
        logger.addAppender(appender);
      }
    }
    this._reporter = new ns.HealthReporter(BRANCH);
    this._reporter.registerProvidersFromCategoryManager(JS_PROVIDERS_CATEGORY);
    this._reporter.start();
    return this._reporter;
  }
get reporter ( ) { if ( ! this . prefs . get ( "serviceEnabled" , true ) ) { return null ; } if ( this . _reporter ) { return this . _reporter ; } let ns = { } ; Cu . import ( "resource://services-common/log4moz.js" , ns ) ; Cu . import ( "resource://gre/modules/services/healthreport/healthreporter.jsm" , ns ) ; const LOGGERS = [ "Metrics" , "Services.HealthReport" , "Services.Metrics" , "Services.BagheeraClient" , ] ; let prefs = new Preferences ( BRANCH + "logging." ) ; if ( prefs . get ( "consoleEnabled" , true ) ) { let level = prefs . get ( "consoleLevel" , "Warn" ) ; let appender = new ns . Log4Moz . ConsoleAppender ( ) ; appender . level = ns . Log4Moz . Level [ level ] || ns . Log4Moz . Level . Warn ; for ( let name of LOGGERS ) { let logger = ns . Log4Moz . repository . getLogger ( name ) ; logger . addAppender ( appender ) ; } } this . _reporter = new ns . HealthReporter ( BRANCH ) ; this . _reporter . registerProvidersFromCategoryManager ( JS_PROVIDERS_CATEGORY ) ; this . _reporter . start ( ) ; return this . _reporter ; }
The HealthReporter instance associated with this service.
The HealthReporter instance associated with this service .
// Lazy import so application startup isn't adversely affected. // How many times will we rewrite this code before rolling it up into a // generic module? See also bug 451283.