1
0
mirror of https://github.com/moparisthebest/FireTray synced 2025-01-06 11:08:04 -05:00

* Linux: add debug for icon theme search path.

* Logging: fix superfluous newline, and expose Log module.

The additional newline was introduced by Log.jsm in FF32 (see
https://bugzilla.mozilla.org/show_bug.cgi?id=966674).
This commit is contained in:
foudfou 2014-11-10 15:06:49 +01:00
parent 0fee978ec3
commit a0c0061cd6
5 changed files with 35 additions and 15 deletions

View File

@ -16,6 +16,8 @@ function glib_defines(lib) {
/* mutual inclusion not possible */
this.GQuark = ctypes.uint32_t; // this.GQuark = gobject.guint32;
this.GError = ctypes.StructType("GError");
lib.lazy_bind("g_strfreev", ctypes.void_t, ctypes.char.ptr.ptr);
};
new ctypes_library(GLIB_LIBNAME, GLIB_ABIS, glib_defines, this);

View File

@ -101,6 +101,7 @@ function gtk_defines(lib) {
lib.lazy_bind("gtk_icon_theme_get_default", this.GtkIconTheme.ptr);
lib.lazy_bind("gtk_icon_theme_get_for_screen", this.GtkIconTheme.ptr, gdk.GdkScreen.ptr);
lib.lazy_bind("gtk_icon_theme_get_search_path", ctypes.void_t, this.GtkIconTheme.ptr, gobject.gchar.ptr.ptr.array(), gobject.gint.ptr);
lib.lazy_bind("gtk_icon_theme_append_search_path", ctypes.void_t, this.GtkIconTheme.ptr, gobject.gchar.ptr);
lib.lazy_bind("gtk_icon_theme_prepend_search_path", ctypes.void_t, this.GtkIconTheme.ptr, gobject.gchar.ptr);
lib.lazy_bind("gtk_icon_theme_choose_icon", this.GtkIconInfo.ptr, this.GtkIconTheme.ptr, gobject.gchar.ptr.array(), gobject.gint, this.GtkIconLookupFlags);

View File

@ -44,6 +44,23 @@ firetray.GtkIcons = {
let gtkIconTheme = gtk.gtk_icon_theme_get_default();
log.debug("gtkIconTheme="+gtkIconTheme);
gtk.gtk_icon_theme_append_search_path(gtkIconTheme, this.GTK_THEME_ICON_PATH);
if (log.level <= firetray.Logging.LogMod.Level.Debug) {
Cu.import("resource://firetray/ctypes/linux/glib.jsm");
Cu.import("resource://firetray/ctypes/linux/gobject.jsm");
firetray.Handler.subscribeLibsForClosing([glib, gobject]);
let path = new gobject.gchar.ptr.ptr;
let n_elements = new gobject.gint;
gtk.gtk_icon_theme_get_search_path(gtkIconTheme, path.address(), n_elements.address());
log.debug("n_elements="+n_elements+" path="+path);
let pathIt = path;
for (let i=0, len=n_elements.value; i<len || pathIt.isNull(); ++i) {
log.debug("path["+i+"]="+pathIt.contents.readString());
pathIt = pathIt.increment();
}
log.debug("path="+path+" pathIt="+pathIt);
glib.g_strfreev(path);
}
}
};

View File

@ -335,7 +335,7 @@ BasicFormatter.prototype = Object.create(Formatter.prototype);
BasicFormatter.prototype.constructor = BasicFormatter;
BasicFormatter.prototype.format = function BF_format(message) {
return message.time + "\t" + message.loggerName + "\t" + message.levelDesc
+ "\t" + message.message + "\n";
+ "\t" + message.message;
};
/*
@ -373,7 +373,7 @@ function DumpAppender(formatter) {
DumpAppender.prototype = Object.create(Appender.prototype);
DumpAppender.prototype.constructor = DumpAppender;
DumpAppender.prototype.doAppend = function DApp_doAppend(message) {
dump(message);
dump(message + "\n");
};
/*

View File

@ -47,11 +47,11 @@ var colorTermLogColors = {
if ("undefined" == typeof(firetray)) {
var firetray = {};
};
var LogMod;
// https://wiki.mozilla.org/Labs/JS_Modules#Logging
firetray.Logging = {
initialized: false,
LogMod: null,
init: function() {
if (this.initialized) return;
@ -65,9 +65,9 @@ firetray.Logging = {
}, this);
if ("undefined" != typeof(Log)) {
LogMod = Log;
this.LogMod = Log;
} else if ("undefined" != typeof(Log4Moz)) {
LogMod = Log4Moz;
this.LogMod = Log4Moz;
} else {
let errMsg = "Log module not found";
dump(errMsg+"\n");
@ -85,8 +85,8 @@ firetray.Logging = {
setupLogging: function(loggerName) {
// lifted from log4moz.js
function SimpleFormatter() {LogMod.Formatter.call(this);}
SimpleFormatter.prototype = Object.create(LogMod.Formatter.prototype);
function SimpleFormatter() {firetray.Logging.LogMod.Formatter.call(this);}
SimpleFormatter.prototype = Object.create(firetray.Logging.LogMod.Formatter.prototype);
SimpleFormatter.prototype.constructor = SimpleFormatter;
SimpleFormatter.prototype.format = function(message) {
let messageString = "";
@ -104,7 +104,7 @@ firetray.Logging = {
date.getSeconds() + "." + date.getMilliseconds();
let stringLog = dateStr + " " +
message.levelDesc + " " + message.loggerName + " " +
messageString + "\n";
messageString;
if (message.exception)
stringLog += message.stackTrace + "\n";
@ -124,14 +124,14 @@ firetray.Logging = {
};
// Loggers are hierarchical, affiliation is handled by a '.' in the name.
this._logger = LogMod.repository.getLogger(loggerName);
this._logger = this.LogMod.repository.getLogger(loggerName);
// Lowering this log level will affect all of our addon output
this._logger.level = LogMod.Level[FIRETRAY_LOG_LEVEL];
this._logger.level = this.LogMod.Level[FIRETRAY_LOG_LEVEL];
// A console appender outputs to the JS Error Console
let simpleFormatter = new SimpleFormatter();
let capp = new LogMod.ConsoleAppender(simpleFormatter);
capp.level = LogMod.Level["Debug"];
let capp = new this.LogMod.ConsoleAppender(simpleFormatter);
capp.level = this.LogMod.Level["Debug"];
this._logger.addAppender(capp);
// A dump appender outputs to standard out
@ -141,13 +141,13 @@ firetray.Logging = {
} else {
dumpFormatter = new SimpleFormatter();
}
let dapp = new LogMod.DumpAppender(dumpFormatter);
dapp.level = LogMod.Level["Debug"];
let dapp = new this.LogMod.DumpAppender(dumpFormatter);
dapp.level = this.LogMod.Level["Debug"];
this._logger.addAppender(dapp);
},
getLogger: function(loggerName){
return LogMod.repository.getLogger(loggerName);
return this.LogMod.repository.getLogger(loggerName);
}
}; // firetray.Logging