|
1 | 1 | # Welcome to stacktrace.js! [](https://codeclimate.com/github/stacktracejs/stacktrace.js) |
2 | 2 | A JavaScript tool that allows you to debug your JavaScript by giving you a [stack trace](http://en.wikipedia.org/wiki/Stack_trace) of function calls leading to an error (or any condition you specify) |
3 | 3 |
|
4 | | -# Usage |
5 | | -Just include stacktrace.js file on your page, and call it like so: |
| 4 | +## Usage |
| 5 | +stacktrace.js is getting a new API! |
6 | 6 |
|
7 | | -```html |
8 | | -<script type="text/javascript" src="https://rawgithub.com/stacktracejs/stacktrace.js/master/stacktrace.js"></script> |
9 | | -<script type="text/javascript"> |
10 | | - // your code... |
11 | | - var trace = printStackTrace(); |
12 | | - alert(trace.join('\n\n')); // Output however you want! |
13 | | - // more code of yours... |
14 | | -</script> |
15 | | -``` |
16 | | - |
17 | | -You can also pass in your own Error to get a stacktrace *not available in IE or Safari 5-* |
| 7 | +Looking for the [stable version](https://github.com/stacktracejs/stacktrace.js/tree/stable)? |
18 | 8 |
|
19 | | -```html |
20 | | -<script type="text/javascript" src="https://rawgithub.com/stacktracejs/stacktrace.js/master/stacktrace.js"></script> |
21 | | -<script type="text/javascript"> |
22 | | - try { |
23 | | - // error producing code |
24 | | - } catch(e) { |
25 | | - var trace = printStackTrace({e: e}); |
26 | | - alert('Error!\n' + 'Message: ' + e.message + '\nStack trace:\n' + trace.join('\n')); |
27 | | - // do something else with error |
28 | | - } |
29 | | -</script> |
30 | | -``` |
31 | | - |
32 | | -Note that error message is not included in stack trace. |
33 | | - |
34 | | -Bookmarklet available on the [project home page](http://stacktracejs.com). |
35 | | - |
36 | | -# Function Instrumentation # |
37 | | -You can now have any (public or privileged) function give you a stacktrace when it is called: |
38 | | - |
39 | | -```javascript |
40 | | -function logStackTrace(stack) { |
41 | | - console.log(stack.join('\n')); |
42 | | -} |
43 | | -var p = new printStackTrace.implementation(); |
44 | | -p.instrumentFunction(this, 'baz', logStackTrace); |
45 | | - |
46 | | -function foo() { |
47 | | - var a = 1; |
48 | | - bar(); |
49 | | -} |
50 | | -function bar() { |
51 | | - baz(); |
52 | | -} |
53 | | -foo(); //Will log a stacktrace when 'baz()' is called containing 'foo()'! |
54 | | - |
55 | | -p.deinstrumentFunction(this, 'baz'); //Remove function instrumentation |
56 | | -``` |
57 | | - |
58 | | -# Get stacktrace.js |
| 9 | +## Get stacktrace.js |
59 | 10 | ``` |
60 | 11 | npm install stacktrace-js |
61 | 12 | bower install stacktrace-js |
62 | 13 | component install stacktrace.js |
63 | 14 | wget https://rawgithub.com/stacktracejs/stacktrace.js/master/stacktrace.js |
64 | 15 | ``` |
65 | 16 |
|
66 | | -# Browser Support |
67 | | -It is currently tested and working on: |
68 | | - |
69 | | - - Firefox (and Iceweasel) 0.9+ |
70 | | - - Google Chrome 1+ |
71 | | - - Safari 3.0+ (including iOS 1+) |
72 | | - - Opera 7+ |
73 | | - - IE 5.5+ |
74 | | - - Konqueror 3.5+ |
75 | | - - Flock 1.0+ |
76 | | - - SeaMonkey 1.0+ |
77 | | - - K-Meleon 1.5.3+ |
78 | | - - Epiphany 2.28.0+ |
79 | | - - Iceape 1.1+ |
80 | | - |
81 | | -## Contributions [](http://waffle.io/stacktracejs/stacktrace.js) |
| 17 | +## Contributions |
82 | 18 |
|
83 | 19 | This project is made possible due to the efforts of these fine people: |
84 | 20 |
|
|
0 commit comments