1

I'm working on a bug logger script for my javascript application. What I would like to do is to attach javascript environment variables to the bug reports (e.g. window.*).

Is there a convenient way to do this in javascript?

Arsen Zahray
  • 24,367
  • 48
  • 131
  • 224
  • 6
    In my browser (Chrome) on this page, there are 539 attributes of `window`, many of which are complex objects. You want them *all* logged, with their values? – user229044 Jun 13 '13 at 16:04
  • 2
    You should think of putting your env variables in one common namespace. – t.niese Jun 13 '13 at 16:07
  • For example, there's a bunch of constructors and static classes, some unassigned event handlers, several browser-defined utility functions... – John Dvorak Jun 13 '13 at 16:07
  • Actually, yeah, that's what I want – Arsen Zahray Jun 13 '13 at 16:07
  • `for(i in window) console.log(i, window[i])` -- Is this what you want? – John Dvorak Jun 13 '13 at 16:08
  • possible duplicate of [Javascript - dumping all global variables](http://stackoverflow.com/questions/8369338/javascript-dumping-all-global-variables) – Felix Kling Jun 13 '13 at 16:09
  • 2
    How do you intend to log complex values, like functions? You're going to wind up with tens of thousands of lines of logging. You're also going to have to dodge recursion, which is particularly hard, as (for the simplest example) `window.window.window.window....` is a thing. – user229044 Jun 13 '13 at 16:10
  • Your question's title mentions "dump window object" but then your actual question then mentions "attach". So which is it; attach or dump? – Kenrick Chien Jun 13 '13 at 16:10
  • There's also the non-trivial issue that navigation to a cross-browser's frame scope kills your script in a way you cannot prevent, easily predict or recover from. – John Dvorak Jun 13 '13 at 16:12
  • @KenrickChien the bug report is being attached to, not the window object. – John Dvorak Jun 13 '13 at 16:13

0 Answers0