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