michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: this.EXPORTED_SYMBOLS = ["TelemetryLog"]; michael@0: michael@0: const Cc = Components.classes; michael@0: const Ci = Components.interfaces; michael@0: michael@0: const Telemetry = Cc["@mozilla.org/base/telemetry;1"].getService(Ci.nsITelemetry); michael@0: var gLogEntries = []; michael@0: michael@0: this.TelemetryLog = Object.freeze({ michael@0: log: function(id, data) { michael@0: id = String(id); michael@0: var ts; michael@0: try { michael@0: ts = Math.floor(Telemetry.msSinceProcessStart()); michael@0: } catch(e) { michael@0: // If timestamp is screwed up, we just give up instead of making up michael@0: // data. michael@0: return; michael@0: } michael@0: michael@0: var entry = [id, ts]; michael@0: if (data !== undefined) { michael@0: entry = entry.concat(Array.prototype.map.call(data, String)); michael@0: } michael@0: gLogEntries.push(entry); michael@0: }, michael@0: michael@0: entries: function() { michael@0: return gLogEntries; michael@0: } michael@0: });