mirror of
https://github.com/moparisthebest/FireTray
synced 2025-01-07 19:48:03 -05:00
Using __proto__ to set a prototype is now deprecated (FF30).
This commit is contained in:
parent
e8890c9ac0
commit
738c412c23
@ -331,13 +331,11 @@ function BasicFormatter(dateFormat) {
|
||||
if (dateFormat)
|
||||
this.dateFormat = dateFormat;
|
||||
}
|
||||
BasicFormatter.prototype = {
|
||||
__proto__: Formatter.prototype,
|
||||
|
||||
format: function BF_format(message) {
|
||||
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";
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
@ -372,12 +370,10 @@ function DumpAppender(formatter) {
|
||||
this._name = "DumpAppender";
|
||||
Appender.call(this, formatter);
|
||||
}
|
||||
DumpAppender.prototype = {
|
||||
__proto__: Appender.prototype,
|
||||
|
||||
doAppend: function DApp_doAppend(message) {
|
||||
DumpAppender.prototype = Object.create(Appender.prototype);
|
||||
DumpAppender.prototype.constructor = DumpAppender;
|
||||
DumpAppender.prototype.doAppend = function DApp_doAppend(message) {
|
||||
dump(message);
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
@ -389,17 +385,14 @@ function ConsoleAppender(formatter) {
|
||||
this._name = "ConsoleAppender";
|
||||
Appender.call(this, formatter);
|
||||
}
|
||||
ConsoleAppender.prototype = {
|
||||
__proto__: Appender.prototype,
|
||||
|
||||
doAppend: function CApp_doAppend(message) {
|
||||
ConsoleAppender.prototype = Object.create(Appender.prototype);
|
||||
ConsoleAppender.prototype.doAppend = function CApp_doAppend(message) {
|
||||
if (message.level > Log4Moz.Level.Warn) {
|
||||
Cu.reportError(message);
|
||||
return;
|
||||
}
|
||||
Cc["@mozilla.org/consoleservice;1"].
|
||||
getService(Ci.nsIConsoleService).logStringMessage(message);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -414,11 +407,10 @@ function BlockingStreamAppender(formatter) {
|
||||
this._name = "BlockingStreamAppender";
|
||||
Appender.call(this, formatter);
|
||||
}
|
||||
BlockingStreamAppender.prototype = {
|
||||
__proto__: Appender.prototype,
|
||||
|
||||
_converterStream: null, // holds the nsIConverterOutputStream
|
||||
_outputStream: null, // holds the underlying nsIOutputStream
|
||||
BlockingStreamAppender.prototype = Object.create(Appender.prototype);
|
||||
BlockingStreamAppender.prototype.constructor = BlockingStreamAppender;
|
||||
BlockingStreamAppender.prototype._converterStream = null, // holds the nsIConverterOutputStream
|
||||
BlockingStreamAppender.prototype._outputStream = null, // holds the underlying nsIOutputStream
|
||||
|
||||
/**
|
||||
* Output stream to write to.
|
||||
@ -427,7 +419,8 @@ BlockingStreamAppender.prototype = {
|
||||
* calling newOutputStream. The resulting raw stream is wrapped in a
|
||||
* nsIConverterOutputStream to ensure text is written as UTF-8.
|
||||
*/
|
||||
get outputStream() {
|
||||
Object.defineProperty(BlockingStreamAppender, "outputStream", {
|
||||
get: function outputStream() {
|
||||
if (!this._outputStream) {
|
||||
// First create a raw stream. We can bail out early if that fails.
|
||||
this._outputStream = this.newOutputStream();
|
||||
@ -446,21 +439,22 @@ BlockingStreamAppender.prototype = {
|
||||
Ci.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER);
|
||||
}
|
||||
return this._converterStream;
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
newOutputStream: function newOutputStream() {
|
||||
BlockingStreamAppender.prototype.newOutputStream = function newOutputStream() {
|
||||
throw "Stream-based appenders need to implement newOutputStream()!";
|
||||
},
|
||||
};
|
||||
|
||||
reset: function reset() {
|
||||
BlockingStreamAppender.prototype.reset = function reset() {
|
||||
if (!this._outputStream) {
|
||||
return;
|
||||
}
|
||||
this.outputStream.close();
|
||||
this._outputStream = null;
|
||||
},
|
||||
};
|
||||
|
||||
doAppend: function doAppend(message) {
|
||||
BlockingStreamAppender.prototype.doAppend = function doAppend(message) {
|
||||
if (!message) {
|
||||
return;
|
||||
}
|
||||
@ -478,7 +472,6 @@ BlockingStreamAppender.prototype = {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -493,28 +486,27 @@ function StorageStreamAppender(formatter) {
|
||||
this._name = "StorageStreamAppender";
|
||||
BlockingStreamAppender.call(this, formatter);
|
||||
}
|
||||
StorageStreamAppender.prototype = {
|
||||
__proto__: BlockingStreamAppender.prototype,
|
||||
StorageStreamAppender.prototype = Object.create(BlockingStreamAppender.prototype);
|
||||
StorageStreamAppender.prototype.constructor = StorageStreamAppender;
|
||||
|
||||
_ss: null,
|
||||
newOutputStream: function newOutputStream() {
|
||||
StorageStreamAppender.prototype._ss = null,
|
||||
StorageStreamAppender.prototype.newOutputStream = function newOutputStream() {
|
||||
let ss = this._ss = Cc["@mozilla.org/storagestream;1"]
|
||||
.createInstance(Ci.nsIStorageStream);
|
||||
ss.init(STREAM_SEGMENT_SIZE, PR_UINT32_MAX, null);
|
||||
return ss.getOutputStream(0);
|
||||
},
|
||||
};
|
||||
|
||||
getInputStream: function getInputStream() {
|
||||
StorageStreamAppender.prototype.getInputStream = function getInputStream() {
|
||||
if (!this._ss) {
|
||||
return null;
|
||||
}
|
||||
return this._ss.newInputStream(0);
|
||||
},
|
||||
};
|
||||
|
||||
reset: function reset() {
|
||||
StorageStreamAppender.prototype.reset = function reset() {
|
||||
BlockingStreamAppender.prototype.reset.call(this);
|
||||
this._ss = null;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -529,25 +521,24 @@ function FileAppender(file, formatter) {
|
||||
this._file = file; // nsIFile
|
||||
BlockingStreamAppender.call(this, formatter);
|
||||
}
|
||||
FileAppender.prototype = {
|
||||
__proto__: BlockingStreamAppender.prototype,
|
||||
FileAppender.prototype = Object.create(BlockingStreamAppender.prototype);
|
||||
FileAppender.prototype.constructor = FileAppender;
|
||||
|
||||
newOutputStream: function newOutputStream() {
|
||||
FileAppender.prototype.newOutputStream = function newOutputStream() {
|
||||
try {
|
||||
return FileUtils.openFileOutputStream(this._file);
|
||||
} catch(e) {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
reset: function reset() {
|
||||
FileAppender.prototype.reset = function reset() {
|
||||
BlockingStreamAppender.prototype.reset.call(this);
|
||||
try {
|
||||
this._file.remove(false);
|
||||
} catch (e) {
|
||||
// File didn't exist in the first place, or we're on Windows. Meh.
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -567,19 +558,19 @@ function RotatingFileAppender(file, formatter, maxSize, maxBackups) {
|
||||
this._maxSize = maxSize;
|
||||
this._maxBackups = maxBackups;
|
||||
}
|
||||
RotatingFileAppender.prototype = {
|
||||
__proto__: FileAppender.prototype,
|
||||
RotatingFileAppender.prototype = Object.create(FileAppender.prototype);
|
||||
RotatingFileAppender.prototype.constructor = RotatingFileAppender;
|
||||
|
||||
doAppend: function doAppend(message) {
|
||||
RotatingFileAppender.prototype.doAppend = function doAppend(message) {
|
||||
FileAppender.prototype.doAppend.call(this, message);
|
||||
try {
|
||||
this.rotateLogs();
|
||||
} catch(e) {
|
||||
dump("Error writing file:" + e + "\n");
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
rotateLogs: function rotateLogs() {
|
||||
RotatingFileAppender.prototype.rotateLogs = function rotateLogs() {
|
||||
if (this._file.exists() && this._file.fileSize < this._maxSize) {
|
||||
return;
|
||||
}
|
||||
@ -600,5 +591,4 @@ RotatingFileAppender.prototype = {
|
||||
}
|
||||
|
||||
// Note: this._file still points to the same file
|
||||
}
|
||||
};
|
||||
|
@ -85,11 +85,10 @@ firetray.Logging = {
|
||||
setupLogging: function(loggerName) {
|
||||
|
||||
// lifted from log4moz.js
|
||||
function SimpleFormatter() {}
|
||||
SimpleFormatter.prototype = {
|
||||
__proto__: LogMod.Formatter.prototype,
|
||||
|
||||
format: function(message) {
|
||||
function SimpleFormatter() {LogMod.Formatter.call(this);}
|
||||
SimpleFormatter.prototype = Object.create(LogMod.Formatter.prototype);
|
||||
SimpleFormatter.prototype.constructor = SimpleFormatter;
|
||||
SimpleFormatter.prototype.format = function(message) {
|
||||
let messageString = "";
|
||||
if (message.hasOwnProperty("message"))
|
||||
messageString = message.message;
|
||||
@ -111,20 +110,17 @@ firetray.Logging = {
|
||||
stringLog += message.stackTrace + "\n";
|
||||
|
||||
return stringLog;
|
||||
}
|
||||
};
|
||||
|
||||
function ColorTermFormatter() {}
|
||||
ColorTermFormatter.prototype = {
|
||||
__proto__: SimpleFormatter.prototype,
|
||||
|
||||
format: function(message) {
|
||||
function ColorTermFormatter() {SimpleFormatter.call(this);}
|
||||
ColorTermFormatter.prototype = Object.create(SimpleFormatter.prototype);
|
||||
ColorTermFormatter.prototype.constructor = ColorTermFormatter;
|
||||
ColorTermFormatter.prototype.format = function(message) {
|
||||
let color = colorTermLogColors[message.levelDesc];
|
||||
let stringLog = SimpleFormatter.prototype.format.call(this, message);
|
||||
stringLog = color + stringLog + COLOR_RESET;
|
||||
|
||||
return stringLog;
|
||||
}
|
||||
};
|
||||
|
||||
// Loggers are hierarchical, affiliation is handled by a '.' in the name.
|
||||
|
Loading…
Reference in New Issue
Block a user