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 #include "mozilla/Logging.h" 12 13 #ifndef PLUGIN_LOGGING // allow external override 14 #define PLUGIN_LOGGING 1 // master compile-time switch for pluging logging 15 #endif 16 17 //////////////////////////////////////////////////////////////////////////////// 18 // Basic Plugin Logging Usage Instructions 19 // 20 // 1. Set this environment variable: MOZ_LOG=<name>:<level> 21 22 // Choose the <name> and <level> from this list (no quotes): 23 24 // Log Names <name> 25 #define NPN_LOG_NAME "PluginNPN" 26 #define NPP_LOG_NAME "PluginNPP" 27 #define PLUGIN_LOG_NAME "Plugin" 28 29 // Levels <level> 30 #define PLUGIN_LOG_ALWAYS mozilla::LogLevel::Error 31 #define PLUGIN_LOG_BASIC mozilla::LogLevel::Info 32 #define PLUGIN_LOG_NORMAL mozilla::LogLevel::Debug 33 #define PLUGIN_LOG_NOISY mozilla::LogLevel::Verbose 34 35 // 2. You can combine logs and levels by separating them with a comma: 36 // My favorite Win32 Example: SET MOZ_LOG=Plugin:5,PluginNPP:5,PluginNPN:5 37 38 // 3. Instead of output going to the console, you can log to a file. Additionally, set the 39 // MOZ_LOG_FILE environment variable to point to the full path of a file. 40 // My favorite Win32 Example: SET MOZ_LOG_FILE=c:\temp\pluginLog.txt 41 42 // 4. For complete information see the Gecko Developer guide: 43 // https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Gecko_Logging 44 45 46 #ifdef PLUGIN_LOGGING 47 48 class nsPluginLogging 49 { 50 public: 51 static mozilla::LazyLogModule gNPNLog; // 4.x NP API, calls into navigator 52 static mozilla::LazyLogModule gNPPLog; // 4.x NP API, calls into plugin 53 static mozilla::LazyLogModule gPluginLog; // general plugin log 54 }; 55 56 #endif // PLUGIN_LOGGING 57 58 // Quick-use macros 59 #ifdef PLUGIN_LOGGING 60 #define NPN_PLUGIN_LOG(a, b) \ 61 PR_BEGIN_MACRO \ 62 MOZ_LOG(nsPluginLogging::gNPNLog, a, b); \ 63 PR_LogFlush(); \ 64 PR_END_MACRO 65 #else 66 #define NPN_PLUGIN_LOG(a, b) 67 #endif 68 69 #ifdef PLUGIN_LOGGING 70 #define NPP_PLUGIN_LOG(a, b) \ 71 PR_BEGIN_MACRO \ 72 MOZ_LOG(nsPluginLogging::gNPPLog, a, b); \ 73 PR_LogFlush(); \ 74 PR_END_MACRO 75 #else 76 #define NPP_PLUGIN_LOG(a, b) 77 #endif 78 79 #ifdef PLUGIN_LOGGING 80 #define PLUGIN_LOG(a, b) \ 81 PR_BEGIN_MACRO \ 82 MOZ_LOG(nsPluginLogging::gPluginLog, a, b); \ 83 PR_LogFlush(); \ 84 PR_END_MACRO 85 #else 86 #define PLUGIN_LOG(a, b) 87 #endif 88 89 #endif // nsPluginLogging_h__ 90 91