sbIPDLog.cpp
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 
32 //------------------------------------------------------------------------------
33 //
34 // iPod device logging imported services.
35 //
36 //------------------------------------------------------------------------------
37 
38 // Local imports.
39 #include "sbIPDLog.h"
40 
41 // Mozilla imports.
42 #include <nsCOMPtr.h>
43 #include <nsIPrefService.h>
44 #include <nsServiceManagerUtils.h>
45 
46 
47 //------------------------------------------------------------------------------
48 //
49 // iPod device logging services.
50 //
51 //------------------------------------------------------------------------------
52 
53 //
54 // Static field initializers.
55 //
56 
57 PRBool sbIPDLog::mInitialized = PR_FALSE;
58 #ifdef PR_LOGGING
59 PRLogModuleInfo* sbIPDLog::mLogModuleInfo = nsnull;
60 #endif
61 PRBool sbIPDLog::mFieldLoggingEnabled = PR_FALSE;
62 
63 
72 void
74 {
75  nsresult rv;
76 
77  // Do nothing if already initialized.
78  if (mInitialized)
79  return;
80 
81  // Initialize the NSPR logging.
82 #ifdef PR_LOGGING
83  mLogModuleInfo = PR_NewLogModule(IPD_LOG_MODULE_NAME);
84 #endif
85 
86  // Read the field logging enabled preference.
87  nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID,
88  &rv);
89  if (NS_SUCCEEDED(rv)) {
90  prefBranch->GetBoolPref(IPD_LOG_FIELD_LOG_ENABLE_PREF,
92  } else {
93  NS_WARNING("Failed to get field logging enabled preference.");
94  }
95 
96  // Mark the logging services as initialized.
97  mInitialized = PR_TRUE;
98 }
99 
100 
#define IPD_LOG_FIELD_LOG_ENABLE_PREF
Definition: sbIPDLog.h:77
static PRBool mFieldLoggingEnabled
Definition: sbIPDLog.h:110
const NS_PREFSERVICE_CONTRACTID
static void Initialize()
Definition: sbIPDLog.cpp:73
Songbird iPod Device Logging Definitions.
static PRBool mInitialized
Definition: sbIPDLog.h:106
#define IPD_LOG_MODULE_NAME
Definition: sbIPDLog.h:76