Server side Javascript logging

View: New views
6 Messages — Rating Filter:   Alert me  

Server side Javascript logging

by jlar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi MochiKit people,

I am a happy MochiKit and Javascript amateur using MochiKit for my
personal marine weather forecast site:

http://www.worldwildweather.com

(I am still struggling with a few Javascript issues so please do not
kill me if it does not work)

During the real world testing of my web site my users have encountered
some Javascript errors. To facilitate debugging and to build a more
robust application I would like to log Javascript errors and info
(using MochiKit.Logging) and send it back to my server for analysis.

Has anyone got an example showing how this is done or maybe just some
pointers to get me started.

Best regards,
Jesper
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "MochiKit" group.
To post to this group, send email to mochikit@...
To unsubscribe from this group, send email to mochikit+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Server side Javascript logging

by niek.kouwenberg@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Ajax.

Catch the JavaScript errors with a try-catch construction, and send
the catched error to a "logging" URL on your server, like:

http://www.worldwildweather.com/log.php?message=<catched error
message>

Niek

On 13 jan, 14:43, Jesper <jesper.webm...@...> wrote:

> Hi MochiKit people,
>
> I am a happy MochiKit and Javascript amateur using MochiKit for my
> personal marine weather forecast site:
>
> http://www.worldwildweather.com
>
> (I am still struggling with a few Javascript issues so please do not
> kill me if it does not work)
>
> During the real world testing of my web site my users have encountered
> some Javascript errors. To facilitate debugging and to build a more
> robust application I would like to log Javascript errors and info
> (using MochiKit.Logging) and send it back to my server for analysis.
>
> Has anyone got an example showing how this is done or maybe just some
> pointers to get me started.
>
> Best regards,
> Jesper

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "MochiKit" group.
To post to this group, send email to mochikit@...
To unsubscribe from this group, send email to mochikit+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Server side Javascript logging

by jlar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi Niek,

On Jan 14, 11:15 am, "niek.kouwenb...@..."
<niek.kouwenb...@...> wrote:
> Catch the JavaScript errors with a try-catch construction, and send
> the catched error to a "logging" URL on your server, like:
>
> http://www.worldwildweather.com/log.php?message=<catched error
> message>

Thanks, I will definitely do that. I guess that I can use the MochiKit
logging method:

var msg = logger.getMessageText();

to send the get all logged information (although I might need to
either put a limit on the size of the message or use a post request).

I would definitely also want to catch unanticipated errors. Would you
do that by putting the entire onload method in a try-catch
construction where the error is reraised (since I would of course not
just cause my users browsers to silently ignore an error) after
sending a log to my server:

window.onload = function() {
  try {
    ...
  } catch(error) {
    var msg = logger.getMessageText();
    sendToMyServer(msg);
    throw error;
  };
};

Or do you have a better approach?

Best regards,
Jesper
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "MochiKit" group.
To post to this group, send email to mochikit@...
To unsubscribe from this group, send email to mochikit+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Server side Javascript logging

by niek.kouwenberg@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


First - I would always use POST for this.

If you catch error, shouldn't you use the message of "error"? Not
anything you've logged...

Re-trowing the error is a good idea, nothing changes for the end user.


On 15 jan, 09:32, Jesper <jesper.webm...@...> wrote:

> Hi Niek,
>
> On Jan 14, 11:15 am, "niek.kouwenb...@..."
>
> <niek.kouwenb...@...> wrote:
> > Catch the JavaScript errors with a try-catch construction, and send
> > the catched error to a "logging" URL on your server, like:
>
> >http://www.worldwildweather.com/log.php?message=<catched error
> > message>
>
> Thanks, I will definitely do that. I guess that I can use the MochiKit
> logging method:
>
> var msg = logger.getMessageText();
>
> to send the get all logged information (although I might need to
> either put a limit on the size of the message or use a post request).
>
> I would definitely also want to catch unanticipated errors. Would you
> do that by putting the entire onload method in a try-catch
> construction where the error is reraised (since I would of course not
> just cause my users browsers to silently ignore an error) after
> sending a log to my server:
>
> window.onload = function() {
>   try {
>     ...
>   } catch(error) {
>     var msg = logger.getMessageText();
>     sendToMyServer(msg);
>     throw error;
>   };
>
> };
>
> Or do you have a better approach?
>
> Best regards,
> Jesper
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "MochiKit" group.
To post to this group, send email to mochikit@...
To unsubscribe from this group, send email to mochikit+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Server side Javascript logging

by troels knak-nielsen-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


You can try hooking a handler up to window.onerror although this chart
suggests that it may only work on certain browsers:

    http://www.quirksmode.org/dom/events/index.html

Maybe there are some browser-specific alternatives for those that
don't support this.

--
troels

On Thu, Jan 15, 2009 at 9:48 AM, niek.kouwenberg@...
<niek.kouwenberg@...> wrote:

>
> First - I would always use POST for this.
>
> If you catch error, shouldn't you use the message of "error"? Not
> anything you've logged...
>
> Re-trowing the error is a good idea, nothing changes for the end user.
>
>
> On 15 jan, 09:32, Jesper <jesper.webm...@...> wrote:
>> Hi Niek,
>>
>> On Jan 14, 11:15 am, "niek.kouwenb...@..."
>>
>> <niek.kouwenb...@...> wrote:
>> > Catch the JavaScript errors with a try-catch construction, and send
>> > the catched error to a "logging" URL on your server, like:
>>
>> >http://www.worldwildweather.com/log.php?message=<catched error
>> > message>
>>
>> Thanks, I will definitely do that. I guess that I can use the MochiKit
>> logging method:
>>
>> var msg = logger.getMessageText();
>>
>> to send the get all logged information (although I might need to
>> either put a limit on the size of the message or use a post request).
>>
>> I would definitely also want to catch unanticipated errors. Would you
>> do that by putting the entire onload method in a try-catch
>> construction where the error is reraised (since I would of course not
>> just cause my users browsers to silently ignore an error) after
>> sending a log to my server:
>>
>> window.onload = function() {
>>   try {
>>     ...
>>   } catch(error) {
>>     var msg = logger.getMessageText();
>>     sendToMyServer(msg);
>>     throw error;
>>   };
>>
>> };
>>
>> Or do you have a better approach?
>>
>> Best regards,
>> Jesper
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "MochiKit" group.
To post to this group, send email to mochikit@...
To unsubscribe from this group, send email to mochikit+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Server side Javascript logging

by jlar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi again,

On Jan 15, 9:48 am, "niek.kouwenb...@..."
<niek.kouwenb...@...> wrote:
> First - I would always use POST for this.

I agree. From the documentation it seems like I can use:

MochiKit.Async.doXHR(...)

for this.

> If you catch error, shouldn't you use the message of "error"? Not
> anything you've logged...

Yes, I forgot to include that (but I would also like to transmit
available logging information for easier debugging).
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "MochiKit" group.
To post to this group, send email to mochikit@...
To unsubscribe from this group, send email to mochikit+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---