Skip to content

Commit

Permalink
Merge branch 'cleanUpLogging' into 'sailfishos-esr52'
Browse files Browse the repository at this point in the history
Clean up logging

See merge request mer-core/embedlite-components!53
  • Loading branch information
rainemak committed May 15, 2020
2 parents 91dc56f + a6aa81f commit 5486cbb
Show file tree
Hide file tree
Showing 43 changed files with 300 additions and 155 deletions.
2 changes: 1 addition & 1 deletion chromehelper/EmbedChromeListener.cpp
Expand Up @@ -5,10 +5,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "EmbedChromeListener.h"
#include "../logger/EmbedComponentsLog.h"

#include "nsServiceManagerUtils.h"
#include "nsIObserverService.h"
#include "mozilla/embedlite/EmbedLog.h"
#include "nsStringGlue.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIDOMWindow.h"
Expand Down
5 changes: 1 addition & 4 deletions chromehelper/EmbedChromeManager.cpp
Expand Up @@ -4,15 +4,12 @@
* 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/. */

#define LOG_COMPONENT "EmbedChromeManager"
#include "mozilla/embedlite/EmbedLog.h"

#include "EmbedChromeManager.h"
#include "EmbedChromeListener.h"
#include "../logger/EmbedComponentsLog.h"

#include "nsServiceManagerUtils.h"
#include "nsIObserverService.h"

#include "nsStringGlue.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIDOMWindow.h"
Expand Down
1 change: 1 addition & 0 deletions chromehelper/Makefile.am
Expand Up @@ -5,6 +5,7 @@ libchromehelper_la_SOURCES = \
EmbedChromeListener.cpp \
EmbedChromeManager.cpp \
nsEmbedChromeModule.cpp \
../logger/EmbedComponentsLog.cpp \
$(NULL)

libchromehelper_la_CPPFLAGS = \
Expand Down
2 changes: 2 additions & 0 deletions embedlite-components.pro
@@ -1,12 +1,14 @@
TEMPLATE = subdirs

SOURCES += chromehelper/*.cpp \
logger/*.cpp \
history/*.cpp \
prompt/*.cpp \
touchhelper/*.cpp \
widgetfactory/*.cpp

HEADERS += chromehelper/*.h \
logger/*.h \
history/*.h \
prompt/*.h \
touchhelper/*.h \
Expand Down
6 changes: 5 additions & 1 deletion jscomps/AboutRedirector.js
Expand Up @@ -6,6 +6,8 @@ const Ci = Components.interfaces;

Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");

Services.scriptloader.loadSubScript("chrome://embedlite/content/Logger.js");

let modules = {
// about:
"": {
Expand Down Expand Up @@ -33,7 +35,9 @@ let modules = {
}
}

function AboutRedirector() {}
function AboutRedirector() {
Logger.debug("JSComp: AboutRedirector.js loaded");
}
AboutRedirector.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]),
classID: Components.ID("{59f3da9a-6c88-11e2-b875-33d1bd379849}"),
Expand Down
6 changes: 5 additions & 1 deletion jscomps/AlertsService.js
Expand Up @@ -8,11 +8,15 @@ const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");

Services.scriptloader.loadSubScript("chrome://embedlite/content/Logger.js");

// -----------------------------------------------------------------------
// Alerts Service
// -----------------------------------------------------------------------

function AlertsService() { }
function AlertsService() {
Logger.debug("JSComp: AlertsService.js loaded");
}

AlertsService.prototype = {
classID: Components.ID("{b98ab6b8-6c88-11e2-99bc-6745f7369235}"),
Expand Down
6 changes: 5 additions & 1 deletion jscomps/ContentPermissionPrompt.js
Expand Up @@ -14,10 +14,14 @@ XPCOMUtils.defineLazyServiceGetter(Services, "embedlite",
"@mozilla.org/embedlite-app-service;1",
"nsIEmbedAppService");

Services.scriptloader.loadSubScript("chrome://embedlite/content/Logger.js");

const kEntities = { "geolocation": "geolocation",
"desktop-notification": "desktopNotification" };

function ContentPermissionPrompt() {}
function ContentPermissionPrompt() {
Logger.debug("JSComp: ContentPermissionPrompt.js loaded");
}

ContentPermissionPrompt.prototype = {
classID: Components.ID("{C6E8C44D-9F39-4AF7-BCC0-76E38A8310F5}"),
Expand Down
5 changes: 5 additions & 0 deletions jscomps/EmbedLiteConsoleListener.js
Expand Up @@ -12,11 +12,16 @@ Components.utils.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyServiceGetter(Services, 'env',
'@mozilla.org/process/environment;1',
'nsIEnvironment');

Services.scriptloader.loadSubScript("chrome://embedlite/content/Logger.js");

// Common helper service

function SPConsoleListener(dumpStdOut) {
this._dumpToStdOut = dumpStdOut;
this._cacheLogs = true;

Logger.debug("JSComp: EmbedLiteConsoleListener.js loaded");
}

SPConsoleListener.prototype = {
Expand Down
3 changes: 3 additions & 0 deletions jscomps/EmbedLiteErrorPageHandler.js
Expand Up @@ -17,10 +17,13 @@ XPCOMUtils.defineLazyServiceGetter(Services, "embedlite",
"@mozilla.org/embedlite-app-service;1",
"nsIEmbedAppService");

Services.scriptloader.loadSubScript("chrome://embedlite/content/Logger.js");

// Common helper service

function EmbedLiteErrorPageHandler()
{
Logger.debug("JSComp: EmbedLiteErrorPageHandler.js loaded");
}

function EventLinkListener(aWindow)
Expand Down
3 changes: 3 additions & 0 deletions jscomps/EmbedLiteFaviconService.js
Expand Up @@ -16,10 +16,13 @@ XPCOMUtils.defineLazyServiceGetter(Services, "embedlite",
"@mozilla.org/embedlite-app-service;1",
"nsIEmbedAppService");

Services.scriptloader.loadSubScript("chrome://embedlite/content/Logger.js");

// Common helper service

function EmbedLiteFaviconService()
{
Logger.debug("JSComp: EmbedLiteFaviconService.js loaded");
}

function resolveGeckoURI(aURI) {
Expand Down
13 changes: 8 additions & 5 deletions jscomps/EmbedLiteGlobalHelper.js
Expand Up @@ -10,10 +10,13 @@ Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://gre/modules/LoginManagerParent.jsm");

Services.scriptloader.loadSubScript("chrome://embedlite/content/Logger.js");

// Common helper service

function EmbedLiteGlobalHelper()
{
Logger.debug("JSComp: EmbedLiteGlobalHelper.js loaded");
}

EmbedLiteGlobalHelper.prototype = {
Expand All @@ -23,28 +26,28 @@ EmbedLiteGlobalHelper.prototype = {
switch(aTopic) {
// Engine DownloadManager notifications
case "app-startup": {
dump("EmbedLiteGlobalHelper app-startup\n");
Logger.debug("EmbedLiteGlobalHelper app-startup");
Services.obs.addObserver(this, "invalidformsubmit", false);
Services.obs.addObserver(this, "xpcom-shutdown", false);
Services.obs.addObserver(this, "profile-after-change", false);
break;
}
case "invalidformsubmit": {
dump("EmbedLiteGlobalHelper invalidformsubmit\n");
Logger.debug("EmbedLiteGlobalHelper invalidformsubmit");
break;
}
case "profile-after-change": {
// Init LoginManager
try {
Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager);
} catch (e) {
dump("E login manager\n");
Logger.warn("E login manager:", e);
}
LoginManagerParent.init();
break;
}
case "xpcom-shutdown": {
dump("EmbedLiteGlobalHelper xpcom-shutdown\n");
Logger.debug("EmbedLiteGlobalHelper xpcom-shutdown");
Services.obs.removeObserver(this, "invalidformsubmit", false);
Services.obs.removeObserver(this, "xpcom-shutdown", false);
break;
Expand All @@ -53,7 +56,7 @@ EmbedLiteGlobalHelper.prototype = {
},

notifyInvalidSubmit: function notifyInvalidSubmit(aFormElement, aInvalidElements) {
dump("NOT IMPLEMENTED Invalid Form Submit, need to do something about it\n");
Logger.warn("NOT IMPLEMENTED Invalid Form Submit, need to do something about it.");
if (!aInvalidElements.length)
return;
},
Expand Down
3 changes: 3 additions & 0 deletions jscomps/EmbedLiteOrientationChangeHandler.js
Expand Up @@ -15,8 +15,11 @@ XPCOMUtils.defineLazyServiceGetter(Services, "embedlite",
"@mozilla.org/embedlite-app-service;1",
"nsIEmbedAppService");

Services.scriptloader.loadSubScript("chrome://embedlite/content/Logger.js");

function EmbedLiteOrientationChangeHandler()
{
Logger.debug("JSComp: EmbedLiteOrientationChangeHandler.js loaded");
}

EmbedLiteOrientationChangeHandler.prototype = {
Expand Down
3 changes: 3 additions & 0 deletions jscomps/EmbedLiteSearchEngine.js
Expand Up @@ -10,9 +10,12 @@ const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");

Services.scriptloader.loadSubScript("chrome://embedlite/content/Logger.js");

// Common helper service
function EmbedLiteSearchEngine()
{
Logger.debug("JSComp: EmbedLiteSearchEngine.js loaded");
}

EmbedLiteSearchEngine.prototype = {
Expand Down
18 changes: 10 additions & 8 deletions jscomps/EmbedLiteSyncService.js
Expand Up @@ -10,6 +10,7 @@ const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");

Services.scriptloader.loadSubScript("chrome://embedlite/content/Logger.js");

function EmbedLiteSyncServiceImpotUtils()
{
Expand All @@ -34,6 +35,7 @@ function EmbedLiteSyncServiceImpotUtils()

function EmbedLiteSyncService()
{
Logger.debug("JSComp: EmbedLiteSyncService.js loaded");
}


Expand All @@ -44,13 +46,13 @@ EmbedLiteSyncService.prototype = {
switch(aTopic) {
// Engine DownloadManager notifications
case "app-startup": {
dump("EmbedLiteSyncService app-startup\n");
Logger.debug("EmbedLiteSyncService app-startup");
Services.prefs.setCharPref("services.sync.registerEngines", "Tab,Bookmarks,Form,History,Password,Prefs");
Services.obs.addObserver(this, "embedui:initsync", true);
break;
}
case "embedui:initsync": {
dump("EmbedLiteSyncService embedui:initsync\n");
Logger.debug("EmbedLiteSyncService embedui:initsync");
var data = JSON.parse(aData);
EmbedLiteSyncServiceImpotUtils();
Service.login(data.username, data.password, data.key);
Expand Down Expand Up @@ -80,35 +82,35 @@ EmbedLiteSyncService.prototype = {
embedLiteSyncServiceFetchBookmarks: function () {
this._embedLiteSyncServiceFetch("bookmarks", PlacesItem, function(item) {
if (item.type == "bookmark") {
dump("Title: " + item.title + ", Uri: " + item.bmkUri + "\n");
Logger.debug("Title:", item.title, "Uri:", item.bmkUri);
}
});
},

embedLiteSyncServiceFetchHistory: function () {
this._embedLiteSyncServiceFetch("history", HistoryRec, function(item) {
dump("Title: " + item.title + ", Uri:" + item.histUri + "\n");
Logger.debug("Title:", item.title, "Uri:", item.histUri);
});
},

embedLiteSyncServiceFetchTabs: function () {
this._embedLiteSyncServiceFetch("tabs", TabSetRecord, function(item) {
dump('Tab:' + JSON.stringify(item) + "\n");
Logger.debug("Tab:", JSON.stringify(item));
});
},
embedLiteSyncServiceFetchForms: function () {
this._embedLiteSyncServiceFetch("forms", FormRec, function(item) {
dump('Forms:' + JSON.stringify(item) + "\n");
Logger.debug("Forms:", JSON.stringify(item));
});
},
embedLiteSyncServiceFetchPassword: function () {
this._embedLiteSyncServiceFetch("passwords", LoginRec, function(item) {
dump('Login:' + JSON.stringify(item) + "\n");
Logger.debug("Login:", JSON.stringify(item));
});
},
embedLiteSyncServiceFetchPrefs: function () {
this._embedLiteSyncServiceFetch("prefs", PrefRec, function(item) {
dump('Pref:' + JSON.stringify(item) + "\n");
Logger.debug("Pref:", JSON.stringify(item));
});
},

Expand Down
3 changes: 3 additions & 0 deletions jscomps/EmbedLiteWebAppInstall.js
Expand Up @@ -10,8 +10,11 @@ const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");

Services.scriptloader.loadSubScript("chrome://embedlite/content/Logger.js");

function EmbedLiteWebAppInstall()
{
Logger.debug("JSComp: EmbedLiteWebAppInstall.js loaded");
}

EmbedLiteWebAppInstall.prototype = {
Expand Down
10 changes: 6 additions & 4 deletions jscomps/EmbedPrefService.js
Expand Up @@ -9,13 +9,15 @@ const Cr = Components.results;
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");

Services.scriptloader.loadSubScript("chrome://embedlite/content/Logger.js");

// -----------------------------------------------------------------------
// Download Manager UI
// -----------------------------------------------------------------------

function EmbedPrefService()
{
dump("PREFS SERVICE INITAILIZED\n");
Logger.debug("JSComp: EmbedPrefService.js loaded");
}

EmbedPrefService.prototype = {
Expand Down Expand Up @@ -65,7 +67,7 @@ EmbedPrefService.prototype = {
switch(aTopic) {
// Engine DownloadManager notifications
case "app-startup": {
dump("EmbedPrefService app-startup\n");
Logger.debug("EmbedPrefService app-startup");
Services.obs.addObserver(this, "embedui:prefs", true);
Services.obs.addObserver(this, "embedui:saveprefs", true);
Services.obs.addObserver(this, "embedui:allprefs", true);
Expand All @@ -77,10 +79,10 @@ EmbedPrefService.prototype = {
}
case "embedui:prefs": {
var data = JSON.parse(aData);
dump("UI Wants some prefs back: " + data.msg + "\n");
Logger.debug("UI Wants some prefs back:", data.msg);
let retPrefs = [];
for (let pref of data.prefs) {
dump("pref: " + pref + "\n");
Logger.debug("pref:", pref);
switch (Services.prefs.getPrefType(pref)) {
case Services.prefs.PREF_BOOL:
retPrefs.push({ name: pref, value: Services.prefs.getBoolPref(pref)});
Expand Down
8 changes: 5 additions & 3 deletions jscomps/EmbedliteDownloadManager.js
Expand Up @@ -23,6 +23,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "Services",
XPCOMUtils.defineLazyModuleGetter(this, "Task",
"resource://gre/modules/Task.jsm");

Services.scriptloader.loadSubScript("chrome://embedlite/content/Logger.js");

////////////////////////////////////////////////////////////////////////////////
//// DownloadViewer

Expand Down Expand Up @@ -73,7 +75,7 @@ let DownloadView = {
}

if (download.error) {
dump("EmbedliteDownloadManager error: " + download.error.message + "\n");
Logger.warn("EmbedliteDownloadManager error:", download.error.message);
Services.obs.notifyObservers(null, "embed:download",
JSON.stringify({
msg: "dl-fail",
Expand Down Expand Up @@ -112,7 +114,7 @@ let DownloadView = {
this.prevState[download].succeeded = download.succeeded;

if (!this.prevState[download].error && download.error) {
dump("EmbedliteDownloadManager error: " + download.error.message + "\n");
Logger.debug("EmbedliteDownloadManager error:", download.error.message);
Services.obs.notifyObservers(null, "embed:download",
JSON.stringify({
msg: "dl-fail",
Expand Down Expand Up @@ -155,7 +157,7 @@ let DownloadView = {

function EmbedliteDownloadManager()
{
dump("EmbedliteDownloadManager initialized\n");
Logger.debug("JSComp: EmbedliteDownloadManager.js loaded");
}

EmbedliteDownloadManager.prototype = {
Expand Down

0 comments on commit 5486cbb

Please sign in to comment.