michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* Plugin Module Logging usage instructions and includes */ michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: #ifndef nsPluginLogging_h__ michael@0: #define nsPluginLogging_h__ michael@0: michael@0: #define FORCE_PR_LOG /* Allow logging in the release build */ michael@0: #define PR_LOGGING 1 michael@0: michael@0: #ifdef PR_LOGGING michael@0: #include "prlog.h" michael@0: michael@0: #ifndef PLUGIN_LOGGING // allow external override michael@0: #define PLUGIN_LOGGING 1 // master compile-time switch for pluging logging michael@0: #endif michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: // Basic Plugin Logging Usage Instructions michael@0: // michael@0: // 1. Set this environment variable: NSPR_LOG_MODULES=: michael@0: michael@0: // Choose the and from this list (no quotes): michael@0: michael@0: // Log Names michael@0: #define NPN_LOG_NAME "PluginNPN" michael@0: #define NPP_LOG_NAME "PluginNPP" michael@0: #define PLUGIN_LOG_NAME "Plugin" michael@0: michael@0: // Levels michael@0: #define PLUGIN_LOG_ALWAYS 1 michael@0: #define PLUGIN_LOG_BASIC 3 michael@0: #define PLUGIN_LOG_NORMAL 5 michael@0: #define PLUGIN_LOG_NOISY 7 michael@0: #define PLUGIN_LOG_MAX 9 michael@0: michael@0: // 2. You can combine logs and levels by separating them with a comma: michael@0: // My favorite Win32 Example: SET NSPR_LOG_MODULES=Plugin:5,PluginNPP:5,PluginNPN:5 michael@0: michael@0: // 3. Instead of output going to the console, you can log to a file. Additionally, set the michael@0: // NSPR_LOG_FILE environment variable to point to the full path of a file. michael@0: // My favorite Win32 Example: SET NSPR_LOG_FILE=c:\temp\pluginLog.txt michael@0: michael@0: // 4. For complete information see the NSPR Reference: michael@0: // http://www.mozilla.org/projects/nspr/reference/html/prlog.html michael@0: michael@0: michael@0: #ifdef PLUGIN_LOGGING michael@0: michael@0: class nsPluginLogging michael@0: { michael@0: public: michael@0: static PRLogModuleInfo* gNPNLog; // 4.x NP API, calls into navigator michael@0: static PRLogModuleInfo* gNPPLog; // 4.x NP API, calls into plugin michael@0: static PRLogModuleInfo* gPluginLog; // general plugin log michael@0: }; michael@0: michael@0: #endif // PLUGIN_LOGGING michael@0: michael@0: #endif // PR_LOGGING michael@0: michael@0: // Quick-use macros michael@0: #ifdef PLUGIN_LOGGING michael@0: #define NPN_PLUGIN_LOG(a, b) \ michael@0: PR_BEGIN_MACRO \ michael@0: PR_LOG(nsPluginLogging::gNPNLog, a, b); \ michael@0: PR_LogFlush(); \ michael@0: PR_END_MACRO michael@0: #else michael@0: #define NPN_PLUGIN_LOG(a, b) michael@0: #endif michael@0: michael@0: #ifdef PLUGIN_LOGGING michael@0: #define NPP_PLUGIN_LOG(a, b) \ michael@0: PR_BEGIN_MACRO \ michael@0: PR_LOG(nsPluginLogging::gNPPLog, a, b); \ michael@0: PR_LogFlush(); \ michael@0: PR_END_MACRO michael@0: #else michael@0: #define NPP_PLUGIN_LOG(a, b) michael@0: #endif michael@0: michael@0: #ifdef PLUGIN_LOGGING michael@0: #define PLUGIN_LOG(a, b) \ michael@0: PR_BEGIN_MACRO \ michael@0: PR_LOG(nsPluginLogging::gPluginLog, a, b); \ michael@0: PR_LogFlush(); \ michael@0: PR_END_MACRO michael@0: #else michael@0: #define PLUGIN_LOG(a, b) michael@0: #endif michael@0: michael@0: #endif // nsPluginLogging_h__ michael@0: