1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/plugins/base/nsPluginLogging.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,97 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +/* Plugin Module Logging usage instructions and includes */ 1.10 +//////////////////////////////////////////////////////////////////////////////// 1.11 +#ifndef nsPluginLogging_h__ 1.12 +#define nsPluginLogging_h__ 1.13 + 1.14 +#define FORCE_PR_LOG /* Allow logging in the release build */ 1.15 +#define PR_LOGGING 1 1.16 + 1.17 +#ifdef PR_LOGGING 1.18 +#include "prlog.h" 1.19 + 1.20 +#ifndef PLUGIN_LOGGING // allow external override 1.21 +#define PLUGIN_LOGGING 1 // master compile-time switch for pluging logging 1.22 +#endif 1.23 + 1.24 +//////////////////////////////////////////////////////////////////////////////// 1.25 +// Basic Plugin Logging Usage Instructions 1.26 +// 1.27 +// 1. Set this environment variable: NSPR_LOG_MODULES=<name>:<level> 1.28 + 1.29 +// Choose the <name> and <level> from this list (no quotes): 1.30 + 1.31 +// Log Names <name> 1.32 +#define NPN_LOG_NAME "PluginNPN" 1.33 +#define NPP_LOG_NAME "PluginNPP" 1.34 +#define PLUGIN_LOG_NAME "Plugin" 1.35 + 1.36 +// Levels <level> 1.37 +#define PLUGIN_LOG_ALWAYS 1 1.38 +#define PLUGIN_LOG_BASIC 3 1.39 +#define PLUGIN_LOG_NORMAL 5 1.40 +#define PLUGIN_LOG_NOISY 7 1.41 +#define PLUGIN_LOG_MAX 9 1.42 + 1.43 +// 2. You can combine logs and levels by separating them with a comma: 1.44 +// My favorite Win32 Example: SET NSPR_LOG_MODULES=Plugin:5,PluginNPP:5,PluginNPN:5 1.45 + 1.46 +// 3. Instead of output going to the console, you can log to a file. Additionally, set the 1.47 +// NSPR_LOG_FILE environment variable to point to the full path of a file. 1.48 +// My favorite Win32 Example: SET NSPR_LOG_FILE=c:\temp\pluginLog.txt 1.49 + 1.50 +// 4. For complete information see the NSPR Reference: 1.51 +// http://www.mozilla.org/projects/nspr/reference/html/prlog.html 1.52 + 1.53 + 1.54 +#ifdef PLUGIN_LOGGING 1.55 + 1.56 +class nsPluginLogging 1.57 +{ 1.58 +public: 1.59 + static PRLogModuleInfo* gNPNLog; // 4.x NP API, calls into navigator 1.60 + static PRLogModuleInfo* gNPPLog; // 4.x NP API, calls into plugin 1.61 + static PRLogModuleInfo* gPluginLog; // general plugin log 1.62 +}; 1.63 + 1.64 +#endif // PLUGIN_LOGGING 1.65 + 1.66 +#endif // PR_LOGGING 1.67 + 1.68 +// Quick-use macros 1.69 +#ifdef PLUGIN_LOGGING 1.70 + #define NPN_PLUGIN_LOG(a, b) \ 1.71 + PR_BEGIN_MACRO \ 1.72 + PR_LOG(nsPluginLogging::gNPNLog, a, b); \ 1.73 + PR_LogFlush(); \ 1.74 + PR_END_MACRO 1.75 +#else 1.76 + #define NPN_PLUGIN_LOG(a, b) 1.77 +#endif 1.78 + 1.79 +#ifdef PLUGIN_LOGGING 1.80 + #define NPP_PLUGIN_LOG(a, b) \ 1.81 + PR_BEGIN_MACRO \ 1.82 + PR_LOG(nsPluginLogging::gNPPLog, a, b); \ 1.83 + PR_LogFlush(); \ 1.84 + PR_END_MACRO 1.85 +#else 1.86 + #define NPP_PLUGIN_LOG(a, b) 1.87 +#endif 1.88 + 1.89 +#ifdef PLUGIN_LOGGING 1.90 + #define PLUGIN_LOG(a, b) \ 1.91 + PR_BEGIN_MACRO \ 1.92 + PR_LOG(nsPluginLogging::gPluginLog, a, b); \ 1.93 + PR_LogFlush(); \ 1.94 + PR_END_MACRO 1.95 +#else 1.96 + #define PLUGIN_LOG(a, b) 1.97 +#endif 1.98 + 1.99 +#endif // nsPluginLogging_h__ 1.100 +