IP Library › Granted Patent US 8,245,200
Granted Patent B2
US 8,245,200 · App. 12/171,935 · Granted Aug 14, 2012

Method, system, and apparatus for dynamically injecting logging statements into web 2.0 javascript applications

Assignee: International Business Machines Corporation
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 8,245,200
App. No.
12/171,935
Granted
Aug 14, 2012
Kind
B2
Abstract

A Method, System and Apparatus for dynamically injecting logging statements into Web 2.0 JavaScript applications includes a single block of JavaScript code configured to execute on a client device by loading a profiler JavaScript code into memory on the client device and registering a target JavaScript object. The profiler JavaScript code is configured to dynamically scan the user-defined JavaScript code and modify the functions to add events to a modified user-defined code which include an identification of when the function was called, when the function was exited and when an exception occurs. The modification module is wrapped into a try/catch block so that exceptions can be handled and posted back to the server or displayed to the user or developer.

Claims (30)

1. A computer program product for tracing JavaScript code execution on a client device executing JavaScript code, the computer program product comprising a single block of JavaScript code configured to execute on the client device, the operations of the computer program product comprising:

receiving profiler JavaScript code from a server;

receiving user-defined JavaScript code from the server;

loading the profiler JavaScript code in the memory on the client device, the profiler JavaScript code configured to dynamically redefine each function of a registered target JavaScript object in the memory on the client device;

loading the user-defined JavaScript code in memory on the client device, the user-defined JavaScript code comprising a registration JavaScript instruction;

registering a target JavaScript object in a memory on the client device, in response to loading a registration JavaScript instruction, the registration JavaScript instruction identifying the target JavaScript object, the target JavaScript object defined in the user-defined JavaScript code, the profiler JavaScript code dynamically loading the registered target JavaScript object;

modifying the user-defined JavaScript code at runtime in memory on the client device for each JavaScript object identified by a registration JavaScript instruction in the user-defined JavaScript code by injecting a logging code into the JavaScript object and storing the modified user-defined JavaScript object in memory on the client device, the logging code comprising;

an event added to each function of the target JavaScript object of the modified user-defined JavaScript object identifying when the function of the target JavaScript object is called;

an event added to each function of the target JavaScript object of the modified user-defined JavaScript code identifying when the function of the target JavaScript object is exited; and

an event added to each function of the target JavaScript object of the modified user-defined JavaScript code identifying when an exception occurs within the function of the target JavaScript object;

logging execution of each function of the modified user-defined JavaScript object in response to runtime calls to the function of the modified user-defined JavaScript object from the user-defined JavaScript code; and

outputting the log.

2. The computer program product of claim 1 , wherein outputting the log comprises displaying the log in a user interface of the client device.

3. The computer program product of claim 1 , wherein outputting the log comprises displaying a message describing an exception in a user interface of the client device.

4. The computer program product of claim 1 , wherein outputting the log comprises posting the log to a server that sent the user-defined JavaScript code.

5. A method for tracing JavaScript code execution on a client device executing JavaScript code, the method comprising:

receiving profiler JavaScript code from a server;

receiving user-defined JavaScript code from the server;

loading the profiler JavaScript code in a memory on the client device, the profiler JavaScript code configured to dynamically redefine each function of a registered target JavaScript object in the memory on the client device;

loading the user-defined JavaScript code in memory on the client device, the user-defined JavaScript code comprising a registration JavaScript instruction;

registering a target JavaScript object in a memory on the client device, in response to loading a registration JavaScript instruction, the registration JavaScript instruction identifying the target JavaScript object, the target JavaScript object defined in the user-defined JavaScript code, the profiler JavaScript code dynamically loading the registered target JavaScript object;

modifying the user-defined JavaScript code at runtime in memory on the client device for each JavaScript object identified by a registration JavaScript instruction in the user-defined JavaScript code by injecting a logging code into the JavaScript object and storing the modified user-defined JavaScript object in memory on the client device, the logging code comprising;

an event added to each function of the target JavaScript object of the modified user-defined JavaScript object identifying when the function of the target JavaScript object is called;

an event added to each function of the target JavaScript object of the modified user-defined JavaScript code identifying when the function of the target JavaScript object is exited; and

an event added to each function of the target JavaScript object of the modified user-defined JavaScript code identifying when an exception occurs within the function of the target JavaScript object;

logging execution of each function of the modified user-defined JavaScript object in response to runtime calls to the function of the modified user-defined JavaScript object from the user-defined JavaScript code; and

outputting the log.

6. The method of claim 5 , wherein outputting the log comprises displaying the log in a user interface of the client device.

7. The method of claim 5 , wherein outputting the log comprises displaying a message describing an exception in a user interface of the client device.

8. The method of claim 5 , wherein outputting the log comprises posting the log to the server that sent the user-defined JavaScript code.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Sep 9, 2008
From: BAIERL, MICHAEL; WANSCH, PETER
To: INTERNATIONAL BUSINESS MACHINES CORPORATION
Reel/Frame 021500/0269 →
Continuity (1)
Related Publication 20100011341A1 · Jan 14, 2010