Welcome, Guest
Username Password: Remember me

Error handling when writing to the log file
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: Error handling when writing to the log file

Error handling when writing to the log file 13 years ago #6282

  • doorknob
  • OFFLINE
  • Fresh Boarder
  • Posts: 9
  • Karma: 0
Hi,
I recently installed MJ (v1.0RC4). In trying to set up a test environment with FireFox, I eventually got a "content encryption error" I recovered from that but couldn't then reproduce it! In my experience, this type of problem often traces back to an incorrectly handled fopen() command and so I started looking at those. I found one in plugins/Mobile/terawurfl/TeraWurFl.php and, sure enough, it doesn't allow for the possibility of errors occurring (like the user doesn't have write permission on the file, for example). At line 462, I changed
		$_logFP = fopen($logfile, "a+");
fputs($_logFP, $_textToLog."\n");
fclose($_logFP);
 
to
		$_logFP = @fopen($logfile, "a+");
if (is_resource($_logFP)) {
fputs($_logFP, $_textToLog."\n");
fclose($_logFP);
}
 
I don't know if it is related to the problem I experienced but a bit of defensive coding can't do any harm.
Regards
Phil
Last Edit: 13 years ago by doorknob.

Re: Error handling when writing to the log file 13 years ago #6283

  • dryabov
  • OFFLINE
  • Administrator
  • Denis Ryabov, Lead Developer
  • Posts: 4867
  • Karma: 105
MJ disables writing to log file (look at TeraWurflConfig::$LOG_LEVEL=0; in plugins/mobile/terawurfl.php).

Re: Error handling when writing to the log file 13 years ago #6289

  • doorknob
  • OFFLINE
  • Fresh Boarder
  • Posts: 9
  • Karma: 0
I'm not sure what point you are making.
Do you mean that it doesn't matter because it's redundant code?

Re: Error handling when writing to the log file 13 years ago #6290

  • dryabov
  • OFFLINE
  • Administrator
  • Denis Ryabov, Lead Developer
  • Posts: 4867
  • Karma: 105
Yes, we use TeraWURFL library "as is". The library can save some notices to log file, but we disable this feature by assigning zero value to LOG_LEVEL parameter.
  • Page:
  • 1
Time to create page: 0.13 seconds

By continuing to use this site you consent to the use of cookies on your device as described in our cookie policy unless you have disabled them. This site will not function correctly without cookies.

I accept cookies from this site.