sbIPDLog.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set sw=2 :miv */
3 /*
4 //=BEGIN SONGBIRD GPL
5 //
6 // This file is part of the Songbird web player.
7 //
8 // Copyright(c) 2005-2009 POTI, Inc.
9 // http://www.songbirdnest.com
10 //
11 // This file may be licensed under the terms of of the
12 // GNU General Public License Version 2 (the GPL).
13 //
14 // Software distributed under the License is distributed
15 // on an AS IS basis, WITHOUT WARRANTY OF ANY KIND, either
16 // express or implied. See the GPL for the specific language
17 // governing rights and limitations.
18 //
19 // You should have received a copy of the GPL along with this
20 // program. If not, go to http://www.gnu.org/licenses/gpl.html
21 // or write to the Free Software Foundation, Inc.,
22 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 //
24 //=END SONGBIRD GPL
25 */
26 
27 #ifndef __SB_IPD_LOG_H__
28 #define __SB_IPD_LOG_H__
29 
30 //------------------------------------------------------------------------------
31 //------------------------------------------------------------------------------
32 //
33 // iPod device logging services defs.
34 //
35 // These services provide support for development debugging and end-user field
36 // logging.
37 // Debug logging uses the NSPR logging services. Use the LOG macro for debug
38 // logs. Debug log output can be enabled by setting the environment variable
39 // NSPR_LOG_MODULES to sbIPDModule:5.
40 // Use the FIELD_LOG macro of field logs. These can be enabled by setting the
41 // songbird.ipod.logging.enabled boolean preference to true.
42 //
43 //------------------------------------------------------------------------------
44 //------------------------------------------------------------------------------
45 
51 //------------------------------------------------------------------------------
52 //
53 // iPod device logging imported services.
54 //
55 //------------------------------------------------------------------------------
56 
57 // Mozilla imports.
58 #include <nscore.h>
59 #include <prlog.h>
60 
61 // Standard C imports.
62 #include <stdio.h>
63 
64 
65 //------------------------------------------------------------------------------
66 //
67 // iPod device logging services definitions.
68 //
69 //------------------------------------------------------------------------------
70 
71 //
72 // IPD_LOG_MODULE_NAME Name of log module.
73 // IPD_LOG_FIELD_LOG_ENABLE_PREF Field logging enable preference name.
74 //
75 
76 #define IPD_LOG_MODULE_NAME "sbIPDModule"
77 #define IPD_LOG_FIELD_LOG_ENABLE_PREF "songbird.ipod.logging.enabled"
78 
79 
80 //------------------------------------------------------------------------------
81 //
82 // iPod device logging services classes.
83 //
84 //------------------------------------------------------------------------------
85 
90 class sbIPDLog
91 {
92  //
93  // Public interface.
94  //
95 public:
96  static void Initialize();
97 
98 
99  //
100  // mInitialized True if the logging services have been
101  // initialized.
102  // mLogModuleInfo Log module information.
103  // mFieldLoggingEnabled If true, field logging is enabled.
104  //
105 
106  static PRBool mInitialized;
107 #ifdef PR_LOGGING
108  static PRLogModuleInfo* mLogModuleInfo;
109 #endif
110  static PRBool mFieldLoggingEnabled;
111 };
112 
113 
114 //------------------------------------------------------------------------------
115 //
116 // iPod device logging services macros.
117 //
118 //------------------------------------------------------------------------------
119 
126 #define FIELD_LOG(args) \
127 { \
128  if (sbIPDLog::mFieldLoggingEnabled) { \
129  printf("sbIPDLog: "); \
130  printf args; \
131  } \
132 }
133 
134 
135 #endif /* __SB_IPD_LOG_H__ */
136 
static PRBool mFieldLoggingEnabled
Definition: sbIPDLog.h:110
static void Initialize()
Definition: sbIPDLog.cpp:73
static PRBool mInitialized
Definition: sbIPDLog.h:106