Back to index

lightning-sunbird  0.9+nobinonly
nsPluginLogging.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPL"), or
00026  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 /* Plugin Module Logging usage instructions and includes */
00040 #ifndef nsPluginLogging_h__
00041 #define nsPluginLogging_h__
00042 
00043 #define FORCE_PR_LOG /* Allow logging in the release build */
00044 #define PR_LOGGING 1
00045 
00046 #ifdef PR_LOGGING
00047 #include "prlog.h"
00048 
00049 #ifndef PLUGIN_LOGGING    // allow external override
00050 #define PLUGIN_LOGGING 1  // master compile-time switch for pluging logging
00051 #endif
00052 
00054 // Basic Plugin Logging Usage Instructions
00055 //
00056 // 1. Set this environment variable: NSPR_LOG_MODULES=<name>:<level>
00057 
00058 // Choose the <name> and <level> from this list (no quotes):
00059 
00060 // Log Names            <name>
00061 #define NPN_LOG_NAME    "PluginNPN"
00062 #define NPP_LOG_NAME    "PluginNPP"
00063 #define PLUGIN_LOG_NAME "Plugin"
00064 
00065 // Levels                <level>
00066 #define PLUGIN_LOG_ALWAYS 1
00067 #define PLUGIN_LOG_BASIC  3
00068 #define PLUGIN_LOG_NORMAL 5
00069 #define PLUGIN_LOG_NOISY  7
00070 #define PLUGIN_LOG_MAX    9
00071 
00072 // 2. You can combine logs and levels by separating them with a comma:
00073 //    My favorite Win32 Example: SET NSPR_LOG_MODULES=Plugin:5,PluginNPP:5,PluginNPN:5
00074 
00075 // 3. Instead of output going to the console, you can log to a file. Additionally, set the
00076 //    NSPR_LOG_FILE environment variable to point to the full path of a file.
00077 //    My favorite Win32 Example: SET NSPR_LOG_FILE=c:\temp\pluginLog.txt
00078 
00079 // 4. For complete information see the NSPR Reference: 
00080 //    http://www.mozilla.org/projects/nspr/reference/html/prlog.html
00081 
00082 
00083 #ifdef PLUGIN_LOGGING
00084 
00085 class nsPluginLogging
00086 {
00087 public:
00088   static PRLogModuleInfo* gNPNLog;  // 4.x NP API, calls into navigator
00089   static PRLogModuleInfo* gNPPLog;  // 4.x NP API, calls into plugin
00090   static PRLogModuleInfo* gPluginLog;  // general plugin log
00091 };
00092 
00093 #endif   // PLUGIN_LOGGING
00094 
00095 #endif  // PR_LOGGING
00096 
00097 // Quick-use macros
00098 #ifdef PLUGIN_LOGGING
00099  #define NPN_PLUGIN_LOG(a, b)                              \
00100    PR_BEGIN_MACRO                                        \
00101    PR_LOG(nsPluginLogging::gNPNLog, a, b); \
00102    PR_LogFlush();                                                    \
00103    PR_END_MACRO
00104 #else
00105  #define NPN_PLUGIN_LOG(a, b)
00106 #endif
00107 
00108 #ifdef PLUGIN_LOGGING
00109  #define NPP_PLUGIN_LOG(a, b)                              \
00110    PR_BEGIN_MACRO                                         \
00111    PR_LOG(nsPluginLogging::gNPPLog, a, b); \
00112    PR_LogFlush();                                                    \
00113    PR_END_MACRO
00114 #else
00115  #define NPP_PLUGIN_LOG(a, b)
00116 #endif
00117 
00118 #ifdef PLUGIN_LOGGING
00119  #define PLUGIN_LOG(a, b)                              \
00120    PR_BEGIN_MACRO                                         \
00121    PR_LOG(nsPluginLogging::gPluginLog, a, b); \
00122    PR_LogFlush();                                                    \
00123    PR_END_MACRO
00124 #else
00125  #define PLUGIN_LOG(a, b)
00126 #endif
00127 
00128 #endif   // nsPluginLogging_h__
00129