瀏覽代碼

Use logTag in StateService

Danilo Bargen 9 年之前
父節點
當前提交
623fac1092
共有 1 個文件被更改,包括 10 次插入8 次删除
  1. 10 8
      src/services/state.ts

+ 10 - 8
src/services/state.ts

@@ -17,6 +17,8 @@
 
 export class StateService {
 
+    private logTag: string = '[StateService]';
+
     // Angular services
     private $log: ng.ILogService;
     private $interval: ng.IIntervalService;
@@ -50,7 +52,7 @@ export class StateService {
         const prevState = this.signalingConnectionState;
         this.signalingConnectionState = state;
         if (this.stage === 'signaling') {
-            this.$log.debug('[StateService] Signaling connection state:', prevState, '=>', state);
+            this.$log.debug(this.logTag, 'Signaling connection state:', prevState, '=>', state);
             switch (state) {
                 case 'new':
                 case 'ws-connecting':
@@ -67,10 +69,10 @@ export class StateService {
                     this.state = 'error';
                     break;
                 default:
-                    this.$log.warn('[StateService] Ignored signaling connection state change to', state);
+                    this.$log.warn(this.logTag, 'Ignored signaling connection state change to', state);
             }
         } else {
-            this.$log.debug('[StateService] Ignored signaling connection state to "' + state + '"');
+            this.$log.debug(this.logTag, 'Ignored signaling connection state to "' + state + '"');
         }
     }
 
@@ -81,7 +83,7 @@ export class StateService {
         const prevState = this.rtcConnectionState;
         this.rtcConnectionState = state;
         if (this.stage === 'rtc') {
-            this.$log.debug('[StateService] RTC connection state:', prevState, '=>', state);
+            this.$log.debug(this.logTag, 'RTC connection state:', prevState, '=>', state);
             switch (state) {
                 case 'new':
                 case 'connecting':
@@ -95,10 +97,10 @@ export class StateService {
                     this.state = 'error';
                     break;
                 default:
-                    this.$log.warn('[StateService] Ignored RTC connection state change to', state);
+                    this.$log.warn(this.logTag, 'Ignored RTC connection state change to', state);
             }
         } else {
-            this.$log.debug('[StateService] Ignored RTC connection state change to "' + state + '"');
+            this.$log.debug(this.logTag, 'Ignored RTC connection state change to "' + state + '"');
         }
     }
 
@@ -109,7 +111,7 @@ export class StateService {
         if (this.connectionBuildupState === state) {
             return;
         }
-        this.$log.debug('[StateService] Connection buildup state:', this.connectionBuildupState, '=>', state);
+        this.$log.debug(this.logTag, 'Connection buildup state:', this.connectionBuildupState, '=>', state);
 
         // Update state
         this.connectionBuildupState = state;
@@ -188,7 +190,7 @@ export class StateService {
      * Reset all states.
      */
     public reset(): void {
-        this.$log.debug('[StateService] Reset');
+        this.$log.debug(this.logTag, 'Reset');
 
         // Reset state
         this.signalingConnectionState = 'new';