Browse Source

Add log API to Blob and XMLHttpRequest

Ben Hsieh 8 years ago
parent
commit
274d526476
3 changed files with 15 additions and 0 deletions
  1. 7
    0
      src/polyfill/Blob.js
  2. 7
    0
      src/polyfill/XMLHttpRequest.js
  3. 1
    0
      src/utils/log.js

+ 7
- 0
src/polyfill/Blob.js View File

50
     return this._ref
50
     return this._ref
51
   }
51
   }
52
 
52
 
53
+  static setLog(level:number) {
54
+    if(number === -1)
55
+      log.disable()
56
+    else
57
+      log.level(level)
58
+  }
59
+
53
   /**
60
   /**
54
    * RNFetchBlob Blob polyfill, create a Blob directly from file path, BASE64
61
    * RNFetchBlob Blob polyfill, create a Blob directly from file path, BASE64
55
    * encoded data, and string. The conversion is done implicitly according to
62
    * encoded data, and string. The conversion is done implicitly according to

+ 7
- 0
src/polyfill/XMLHttpRequest.js View File

83
     return DONE
83
     return DONE
84
   }
84
   }
85
 
85
 
86
+  static setLog(level:number) {
87
+    if(number === -1)
88
+      log.disable()
89
+    else
90
+      log.level(level)
91
+  }
92
+
86
   static addBinaryContentType(substr:string) {
93
   static addBinaryContentType(substr:string) {
87
     for(let i in XMLHttpRequest.binaryContentTypes) {
94
     for(let i in XMLHttpRequest.binaryContentTypes) {
88
       if(new RegExp(substr,'i').test(XMLHttpRequest.binaryContentTypes[i])) {
95
       if(new RegExp(substr,'i').test(XMLHttpRequest.binaryContentTypes[i])) {

+ 1
- 0
src/utils/log.js View File

9
   }
9
   }
10
 
10
 
11
   level(val:number) {
11
   level(val:number) {
12
+    this._isEnable = true
12
     this._level = val
13
     this._level = val
13
   }
14
   }
14
 
15