As a security precaution, we have turned on the setting "Require API key authentication for API requests" for everyone. If this has broken something, please contact
Last Comment Bug 660369 - Consolidate widget debug output, use nspr logging instead of printing to stdout
: Consolidate widget debug output, use nspr logging instead of printing to stdout
Product: Core
Classification: Components
Component: Widget: Win32 (show other bugs)
: Trunk
: x86 Windows 7
: -- normal (vote)
: mozilla9
Assigned To: Brian R. Bondy [:bbondy]
: Jim Mathies [:jimm]
Depends on:
  Show dependency treegraph
Reported: 2011-05-27 15:57 PDT by Jim Mathies [:jimm]
Modified: 2011-08-17 04:44 PDT (History)
3 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

Patch for normalizing logging (39.64 KB, patch)
2011-08-10 09:45 PDT, Brian R. Bondy [:bbondy]
jmathies: review+
roc: superreview+
Details | Diff | Splinter Review

Description User image Jim Mathies [:jimm] 2011-05-27 15:57:57 PDT
I have been meaning to get to this ever since we did the big reformat of nsWindow. We have pretty good debug output in various areas in Windows widget which is controlled by nsWindowDbg, but the output goes to mixed locations.
Comment 1 User image Brian R. Bondy [:bbondy] 2011-08-10 04:19:36 PDT
I have a couple tasks that will require me to add logging so I might as well take this to refresh myself on NSPR logging.
Comment 2 User image Jim Mathies [:jimm] 2011-08-10 04:56:08 PDT
I would like to see all of this piped through logging or the console, based on a compile switch. I tend to use the console in cases where I need to do some quick debugging.
Comment 3 User image Brian R. Bondy [:bbondy] 2011-08-10 05:42:57 PDT
You can already use an environment variable called NSPR_LOG_MODULES of the format moduleName:level[, moduleName:level]* to control logging

Another environment variable NSPR_LOG_FILE allows you to set the filename and for windows you can use a special value of WinDebug to go to the debug output window in VS.
Comment 4 User image Brian R. Bondy [:bbondy] 2011-08-10 05:43:17 PDT
Comment 5 User image Brian R. Bondy [:bbondy] 2011-08-10 09:26:38 PDT
OK I investigated a bit more and this (see below) seems to be the best option, is convenient, *does not require a restart of Visual Studio*.  

I'll put a comment with the same content (see below) in nsDef.h so we can update it over time as more logging is added and we can refer there as a reference.  I can change if you really want but I think it is flexible and matches the rest of the modules we log in Firefox/Core/Other.  If you want it to be compile time instead we could programatically set the env variables but I think this is not needed.  Likewise re-implementing the same logging to stdout/debug window/file that already exists in NSPR logging with compile time options seems like it is uneeded too.


Logging can be changed at runtime without recompiling in the General property page of Visual Studio under the "Environment" property.

Two variables are of importance to be set: NSPR_LOG_MODULES and NSPR_LOG_FILE

NSPR_LOG_MODULES=all:5 (To log everything completely)
NSPR_LOG_MODULES=nsWindow:5,nsSound:5,nsClipboard:5 (To log windows widget stuff)

NSPR_LOG_FILE=C:\nsprlog.txt   (To a file on disk)
NSPR_LOG_FILE=WinDebug         (To the debug window)
NSPR_LOG_FILE=                 (To stdout/stderr)
Comment 6 User image Brian R. Bondy [:bbondy] 2011-08-10 09:45:51 PDT
Created attachment 552100 [details] [diff] [review]
Patch for normalizing logging

Since this task is in particular prone to rebasing, if you don't mind, I'd prefer a review on this one before my other reviews.
Comment 7 User image Jim Mathies [:jimm] 2011-08-10 11:59:18 PDT
Comment on attachment 552100 [details] [diff] [review]
Patch for normalizing logging

woot! I like it. Let's run it past roc though to be sure he's ok with the changes.
Comment 8 User image Robert O'Callahan (:roc) (email my personal email if necessary) 2011-08-10 15:06:55 PDT
Comment on attachment 552100 [details] [diff] [review]
Patch for normalizing logging

Review of attachment 552100 [details] [diff] [review]:


Note You need to log in before you can comment on or make changes to this bug.