dom/plugins/base/nsPluginLogging.h

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:35800be97314
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 /* Plugin Module Logging usage instructions and includes */
7 ////////////////////////////////////////////////////////////////////////////////
8 #ifndef nsPluginLogging_h__
9 #define nsPluginLogging_h__
10
11 #define FORCE_PR_LOG /* Allow logging in the release build */
12 #define PR_LOGGING 1
13
14 #ifdef PR_LOGGING
15 #include "prlog.h"
16
17 #ifndef PLUGIN_LOGGING // allow external override
18 #define PLUGIN_LOGGING 1 // master compile-time switch for pluging logging
19 #endif
20
21 ////////////////////////////////////////////////////////////////////////////////
22 // Basic Plugin Logging Usage Instructions
23 //
24 // 1. Set this environment variable: NSPR_LOG_MODULES=<name>:<level>
25
26 // Choose the <name> and <level> from this list (no quotes):
27
28 // Log Names <name>
29 #define NPN_LOG_NAME "PluginNPN"
30 #define NPP_LOG_NAME "PluginNPP"
31 #define PLUGIN_LOG_NAME "Plugin"
32
33 // Levels <level>
34 #define PLUGIN_LOG_ALWAYS 1
35 #define PLUGIN_LOG_BASIC 3
36 #define PLUGIN_LOG_NORMAL 5
37 #define PLUGIN_LOG_NOISY 7
38 #define PLUGIN_LOG_MAX 9
39
40 // 2. You can combine logs and levels by separating them with a comma:
41 // My favorite Win32 Example: SET NSPR_LOG_MODULES=Plugin:5,PluginNPP:5,PluginNPN:5
42
43 // 3. Instead of output going to the console, you can log to a file. Additionally, set the
44 // NSPR_LOG_FILE environment variable to point to the full path of a file.
45 // My favorite Win32 Example: SET NSPR_LOG_FILE=c:\temp\pluginLog.txt
46
47 // 4. For complete information see the NSPR Reference:
48 // http://www.mozilla.org/projects/nspr/reference/html/prlog.html
49
50
51 #ifdef PLUGIN_LOGGING
52
53 class nsPluginLogging
54 {
55 public:
56 static PRLogModuleInfo* gNPNLog; // 4.x NP API, calls into navigator
57 static PRLogModuleInfo* gNPPLog; // 4.x NP API, calls into plugin
58 static PRLogModuleInfo* gPluginLog; // general plugin log
59 };
60
61 #endif // PLUGIN_LOGGING
62
63 #endif // PR_LOGGING
64
65 // Quick-use macros
66 #ifdef PLUGIN_LOGGING
67 #define NPN_PLUGIN_LOG(a, b) \
68 PR_BEGIN_MACRO \
69 PR_LOG(nsPluginLogging::gNPNLog, a, b); \
70 PR_LogFlush(); \
71 PR_END_MACRO
72 #else
73 #define NPN_PLUGIN_LOG(a, b)
74 #endif
75
76 #ifdef PLUGIN_LOGGING
77 #define NPP_PLUGIN_LOG(a, b) \
78 PR_BEGIN_MACRO \
79 PR_LOG(nsPluginLogging::gNPPLog, a, b); \
80 PR_LogFlush(); \
81 PR_END_MACRO
82 #else
83 #define NPP_PLUGIN_LOG(a, b)
84 #endif
85
86 #ifdef PLUGIN_LOGGING
87 #define PLUGIN_LOG(a, b) \
88 PR_BEGIN_MACRO \
89 PR_LOG(nsPluginLogging::gPluginLog, a, b); \
90 PR_LogFlush(); \
91 PR_END_MACRO
92 #else
93 #define PLUGIN_LOG(a, b)
94 #endif
95
96 #endif // nsPluginLogging_h__
97

mercurial