Monitor
From FirebugWiki
(Difference between revisions)
Sebastianz (Talk | contribs) (Separate Command Line API page for monitor()) |
Sebastianz (Talk | contribs) (Added parameter description and examples) |
||
| (One intermediate revision not shown) | |||
| Line 1: | Line 1: | ||
Turns on logging for all calls to a function. | Turns on logging for all calls to a function. | ||
| + | |||
| + | This means whenever that function is called, a log message will be created inside the [[Console Panel]] showing the function name, the parameters and their values. | ||
| + | |||
| + | == Syntax == | ||
| + | <source lang="javascript"> | ||
| + | monitor(fn) | ||
| + | </source> | ||
| + | |||
| + | == Parameters == | ||
| + | === fn === | ||
| + | Function to log calls for. '''(required)''' | ||
| + | |||
| + | == Examples == | ||
| + | Having the following function: | ||
| + | |||
| + | <source lang="javascript" line="true"> | ||
| + | function faculty(n) | ||
| + | { | ||
| + | if (n==1 || n==0) | ||
| + | return 1; | ||
| + | |||
| + | var facNumber = 1; | ||
| + | for (i = 1; i <= n; i++) | ||
| + | facNumber *= i; | ||
| + | |||
| + | return facNumber; | ||
| + | } | ||
| + | </source> | ||
| + | |||
| + | <source lang="javascript"> | ||
| + | monitor(faculty) | ||
| + | </source> | ||
| + | |||
| + | This enables logging of calls to the function <code>faculty()</code>. So calling this function like <code>faculty(5)</code>, a log message like the following will be created: | ||
| + | |||
| + | <source lang="javascript"> | ||
| + | faculty(n=5) | ||
| + | </source> | ||
| + | |||
| + | == See also == | ||
| + | * [[unmonitor]] | ||
| + | * [[Command Line API]] | ||
Latest revision as of 09:59, 18 July 2012
Turns on logging for all calls to a function.
This means whenever that function is called, a log message will be created inside the Console Panel showing the function name, the parameters and their values.
Contents |
[edit] Syntax
monitor(fn)
[edit] Parameters
[edit] fn
Function to log calls for. (required)
[edit] Examples
Having the following function:
function faculty(n)
{if (n==1 || n==0)
return 1;
var facNumber = 1;
for (i = 1; i <= n; i++)
facNumber *= i;
return facNumber;
}
monitor(faculty)
This enables logging of calls to the function faculty(). So calling this function like faculty(5), a log message like the following will be created:
faculty(n=5)