Bug 1348783 - use LazyLogModule for AudioChannel logging. draft
authorAlastor Wu <alwu@mozilla.com>
Tue, 21 Mar 2017 10:38:48 +0800
changeset 501871 17201714f60906ef94ab194ceb9268d5c24a65c5
parent 501466 62ca73fd974dabafa8af3eed0339007c2e58a5a5
child 550023 08648319745fdf42db1b02466e255e4fd0713446
push id50139
push useralwu@mozilla.com
push dateTue, 21 Mar 2017 02:39:12 +0000
bugs1348783
milestone55.0a1
Bug 1348783 - use LazyLogModule for AudioChannel logging. LazyLog can be used easily via adding the pref("logging.MODULE_NAME", DEBUG_LEVEL). It's more convenient than PRLog. MozReview-Commit-ID: T7uSxVAiN3
dom/audiochannel/AudioChannelService.cpp
dom/audiochannel/AudioChannelService.h
--- a/dom/audiochannel/AudioChannelService.cpp
+++ b/dom/audiochannel/AudioChannelService.cpp
@@ -31,16 +31,18 @@
 #endif
 
 #include "mozilla/Preferences.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::hal;
 
+static mozilla::LazyLogModule gAudioChannelLog("AudioChannel");
+
 namespace {
 
 // If true, any new AudioChannelAgent will be muted when created.
 bool sAudioChannelMutedByDefault = false;
 bool sAudioChannelCompeting = false;
 bool sAudioChannelCompetingAllAgents = false;
 bool sXPCOMShuttingDown = false;
 
@@ -221,23 +223,19 @@ AudioChannelService::Get()
   if (sXPCOMShuttingDown) {
     return nullptr;
   }
 
   RefPtr<AudioChannelService> service = gAudioChannelService.get();
   return service.forget();
 }
 
-/* static */ PRLogModuleInfo*
+/* static */ LogModule*
 AudioChannelService::GetAudioChannelLog()
 {
-  static PRLogModuleInfo *gAudioChannelLog;
-  if (!gAudioChannelLog) {
-    gAudioChannelLog = PR_NewLogModule("AudioChannel");
-  }
   return gAudioChannelLog;
 }
 
 /* static */ void
 AudioChannelService::Shutdown()
 {
   if (gAudioChannelService) {
     nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
--- a/dom/audiochannel/AudioChannelService.h
+++ b/dom/audiochannel/AudioChannelService.h
@@ -11,16 +11,17 @@
 #include "nsAutoPtr.h"
 #include "nsIObserver.h"
 #include "nsTObserverArray.h"
 #include "nsTArray.h"
 
 #include "AudioChannelAgent.h"
 #include "nsAttrValue.h"
 #include "mozilla/dom/AudioChannelBinding.h"
+#include "mozilla/Logging.h"
 
 #include <functional>
 
 class nsIRunnable;
 class nsPIDOMWindowOuter;
 struct PRLogModuleInfo;
 
 namespace mozilla {
@@ -97,17 +98,17 @@ public:
   /**
    * Returns the AudioChannelService singleton if one exists.
    * If AudioChannelService doesn't exist, returns null.
    */
   static already_AddRefed<AudioChannelService> Get();
 
   static bool IsAudioChannelMutedByDefault();
 
-  static PRLogModuleInfo* GetAudioChannelLog();
+  static LogModule* GetAudioChannelLog();
 
   static bool IsEnableAudioCompeting();
 
   /**
    * Any audio channel agent that starts playing should register itself to
    * this service, sharing the AudioChannel.
    */
   void RegisterAudioChannelAgent(AudioChannelAgent* aAgent,