Last Comment Bug 1082551 - wrong call in log4moz.js ( "this._fos().XXX(...)" should be "this._fos.XXX(...)" )
: wrong call in log4moz.js ( "this._fos().XXX(...)" should be "this._fos.XXX(.....
Status: RESOLVED FIXED
:
Product: Thunderbird
Classification: Client Software
Component: General (show other bugs)
: Trunk
: x86_64 Linux
-- normal (vote)
: Thunderbird 43.0
Assigned To: Sebastian Hengst [:aryx][:archaeopteryx] (needinfo on intermittent or backout)
:
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-10-14 06:05 PDT by rene
Modified: 2015-09-09 13:16 PDT (History)
4 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---


Attachments
patch, v1 (980 bytes, patch)
2015-08-16 06:13 PDT, Sebastian Hengst [:aryx][:archaeopteryx] (needinfo on intermittent or backout)
mkmelin+mozilla: review+
Details | Diff | Splinter Review

Description User image rene 2014-10-14 06:05:05 PDT
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0
Build ID: 20140927221706

Steps to reproduce:

tried to use FileAppender


Actual results:

Error writing file:
TypeError: this._fos is not a function


Expected results:

file should have opened...

see https://bugzilla.mozilla.org/show_bug.cgi?id=470208

this._fos().write(message, message.length);
should be
this._fos.write(message, message.length);
Comment 1 User image WADA:World Anti-bad-Duping Agency 2014-10-15 00:53:02 PDT
(In reply to rene from comment #0
> Actual results:
> Error writing file:
> TypeError: this._fos is not a function
>
> this._fos().write(message, message.length);
> should be
> this._fos.write(message, message.length);

Code is here.
> http://mxr.mozilla.org/comm-central/source/mailnews/db/gloda/modules/log4moz.js#745

Property, function, is defined by;
> 713 FileAppender.prototype = {
> 714   __proto__: Appender.prototype,
> 715 
> 716   __fos: null,
> 717   get _fos() {
> 718     if (!this.__fos)
> 719       this.openStream();
> 720     return this.__fos;
> 721   },

I believe following(you suggested) will produce "this._fos is undefined".
   this._fos.write(message, message.length);

I think;
   this._fos().write(message, message.length);
should be
   this.__fos.write(message, message.length);
or
   this.get_fos().write(message, message.length);

I guess "__fos" like one(two "_") is for internal use at deeper level of an Object. "this.get_fos()" like one is better used by higher level of an Object.

FYI.
"._fos." (not ".__fos.") is seen in log4moz.js.
> http://mxr.mozilla.org/comm-central/source/mailnews/db/gloda/modules/log4moz.js#783
> 778   doAppend: function RFApp_doAppend(message) {
> 779     if (message === null || message.length <= 0)
> 780       return;
> 781     try {
> 782       this.rotateLogs();
> 783       this._fos.write(message, message.length);   <=  Should be "this.get_fos().write(...)" or "this.__fos.write(...)"
> 784     } catch(e) {
> 785       dump("Error writing file:\n" + e);
> 786     }
Comment 2 User image rene 2014-10-15 11:01:08 PDT
wada wrote:
>   this._fos().write(message, message.length);
>should be
>   this.__fos.write(message, message.length);
>or
>   this.get_fos().write(message, message.length);

no, this._fos (one _, without brackets) uses the getter and delivers this.__fos (two slashes) while ensuring that the stream is already open.

I'm currently using the suggested change https://www.absorb.it/virtual-id/browser/modules/vI_log.js#L292 and it works
Comment 3 User image WADA:World Anti-bad-Duping Agency 2014-10-15 16:03:39 PDT
Sorry, it was "get _fos()" which is getter, instead of "get_fos()"(no space). I missed a space.
Code in "doAppend: function FApp_doAppend" should be "this._fos.write", as written in "doAppend: function RFApp_doAppend".
Comment 4 User image Sebastian Hengst [:aryx][:archaeopteryx] (needinfo on intermittent or backout) 2015-08-16 06:13:10 PDT
Created attachment 8648487 [details] [diff] [review]
patch, v1
Comment 5 User image Magnus Melin 2015-08-16 12:53:39 PDT
Comment on attachment 8648487 [details] [diff] [review]
patch, v1

Review of attachment 8648487 [details] [diff] [review]:
-----------------------------------------------------------------

LGTM, r=mkmelin
Comment 6 User image aleth [:aleth] 2015-09-09 13:13:29 PDT
https://hg.mozilla.org/comm-central/rev/6df59da4dfced548f5950296542f60e044b26b85
Bug 1082551 - log4moz: this._fos() should be this._fos. r=mkmelin

Note You need to log in before you can comment on or make changes to this bug.