diff options
author | 2018-03-18 16:37:21 +0100 | |
---|---|---|
committer | 2018-03-18 16:37:21 +0100 | |
commit | 88faef416eadc891537f03926160e35245125c72 (patch) | |
tree | db97bb469dcda8fb32a52b2c859b3b9988ad3cc5 /src/api | |
parent | fix(Service Tabs): Remove "delete service" context menu when not in developme... (diff) | |
download | ferdium-app-88faef416eadc891537f03926160e35245125c72.tar.gz ferdium-app-88faef416eadc891537f03926160e35245125c72.tar.zst ferdium-app-88faef416eadc891537f03926160e35245125c72.zip |
Replace console logs with debugger
Diffstat (limited to 'src/api')
-rw-r--r-- | src/api/server/LocalApi.js | 8 | ||||
-rw-r--r-- | src/api/server/ServerApi.js | 60 |
2 files changed, 36 insertions, 32 deletions
diff --git a/src/api/server/LocalApi.js b/src/api/server/LocalApi.js index aa3a7d655..4d2497c61 100644 --- a/src/api/server/LocalApi.js +++ b/src/api/server/LocalApi.js | |||
@@ -3,6 +3,8 @@ import du from 'du'; | |||
3 | 3 | ||
4 | import { getServicePartitionsDirectory } from '../../helpers/service-helpers.js'; | 4 | import { getServicePartitionsDirectory } from '../../helpers/service-helpers.js'; |
5 | 5 | ||
6 | const debug = require('debug')('LocalApi'); | ||
7 | |||
6 | const { session } = remote; | 8 | const { session } = remote; |
7 | 9 | ||
8 | export default class LocalApi { | 10 | export default class LocalApi { |
@@ -13,7 +15,7 @@ export default class LocalApi { | |||
13 | du(partitionsDir, (err, size) => { | 15 | du(partitionsDir, (err, size) => { |
14 | if (err) reject(err); | 16 | if (err) reject(err); |
15 | 17 | ||
16 | console.debug('LocalApi::getAppCacheSize resolves', size); | 18 | debug('LocalApi::getAppCacheSize resolves', size); |
17 | resolve(size); | 19 | resolve(size); |
18 | }); | 20 | }); |
19 | }); | 21 | }); |
@@ -22,14 +24,14 @@ export default class LocalApi { | |||
22 | async clearCache(serviceId) { | 24 | async clearCache(serviceId) { |
23 | const s = session.fromPartition(`persist:service-${serviceId}`); | 25 | const s = session.fromPartition(`persist:service-${serviceId}`); |
24 | 26 | ||
25 | console.debug('LocalApi::clearCache resolves', serviceId); | 27 | debug('LocalApi::clearCache resolves', serviceId); |
26 | return new Promise(resolve => s.clearCache(resolve)); | 28 | return new Promise(resolve => s.clearCache(resolve)); |
27 | } | 29 | } |
28 | 30 | ||
29 | async clearAppCache() { | 31 | async clearAppCache() { |
30 | const s = session.defaultSession; | 32 | const s = session.defaultSession; |
31 | 33 | ||
32 | console.debug('LocalApi::clearCache clearAppCache'); | 34 | debug('LocalApi::clearCache clearAppCache'); |
33 | return new Promise(resolve => s.clearCache(resolve)); | 35 | return new Promise(resolve => s.clearCache(resolve)); |
34 | } | 36 | } |
35 | } | 37 | } |
diff --git a/src/api/server/ServerApi.js b/src/api/server/ServerApi.js index 8f3297d13..353faa7f4 100644 --- a/src/api/server/ServerApi.js +++ b/src/api/server/ServerApi.js | |||
@@ -27,6 +27,8 @@ import { | |||
27 | removeServicePartitionDirectory, | 27 | removeServicePartitionDirectory, |
28 | } from '../../helpers/service-helpers.js'; | 28 | } from '../../helpers/service-helpers.js'; |
29 | 29 | ||
30 | const debug = require('debug')('ServerApi'); | ||
31 | |||
30 | module.paths.unshift( | 32 | module.paths.unshift( |
31 | getDevRecipeDirectory(), | 33 | getDevRecipeDirectory(), |
32 | getRecipeDirectory(), | 34 | getRecipeDirectory(), |
@@ -55,7 +57,7 @@ export default class ServerApi { | |||
55 | } | 57 | } |
56 | const u = await request.json(); | 58 | const u = await request.json(); |
57 | 59 | ||
58 | console.debug('ServerApi::login resolves', u); | 60 | debug('ServerApi::login resolves', u); |
59 | return u.token; | 61 | return u.token; |
60 | } | 62 | } |
61 | 63 | ||
@@ -69,7 +71,7 @@ export default class ServerApi { | |||
69 | } | 71 | } |
70 | const u = await request.json(); | 72 | const u = await request.json(); |
71 | 73 | ||
72 | console.debug('ServerApi::signup resolves', u); | 74 | debug('ServerApi::signup resolves', u); |
73 | return u.token; | 75 | return u.token; |
74 | } | 76 | } |
75 | 77 | ||
@@ -82,7 +84,7 @@ export default class ServerApi { | |||
82 | throw request; | 84 | throw request; |
83 | } | 85 | } |
84 | 86 | ||
85 | console.debug('ServerApi::inviteUser'); | 87 | debug('ServerApi::inviteUser'); |
86 | return true; | 88 | return true; |
87 | } | 89 | } |
88 | 90 | ||
@@ -98,7 +100,7 @@ export default class ServerApi { | |||
98 | } | 100 | } |
99 | const r = await request.json(); | 101 | const r = await request.json(); |
100 | 102 | ||
101 | console.debug('ServerApi::retrievePassword'); | 103 | debug('ServerApi::retrievePassword'); |
102 | return r; | 104 | return r; |
103 | } | 105 | } |
104 | 106 | ||
@@ -112,7 +114,7 @@ export default class ServerApi { | |||
112 | const data = await request.json(); | 114 | const data = await request.json(); |
113 | 115 | ||
114 | const user = new UserModel(data); | 116 | const user = new UserModel(data); |
115 | console.debug('ServerApi::userInfo resolves', user); | 117 | debug('ServerApi::userInfo resolves', user); |
116 | 118 | ||
117 | return user; | 119 | return user; |
118 | } | 120 | } |
@@ -128,7 +130,7 @@ export default class ServerApi { | |||
128 | const updatedData = await request.json(); | 130 | const updatedData = await request.json(); |
129 | 131 | ||
130 | const user = Object.assign(updatedData, { data: new UserModel(updatedData.data) }); | 132 | const user = Object.assign(updatedData, { data: new UserModel(updatedData.data) }); |
131 | console.debug('ServerApi::updateUserInfo resolves', user); | 133 | debug('ServerApi::updateUserInfo resolves', user); |
132 | return user; | 134 | return user; |
133 | } | 135 | } |
134 | 136 | ||
@@ -141,7 +143,7 @@ export default class ServerApi { | |||
141 | } | 143 | } |
142 | const data = await request.json(); | 144 | const data = await request.json(); |
143 | 145 | ||
144 | console.debug('ServerApi::deleteAccount resolves', data); | 146 | debug('ServerApi::deleteAccount resolves', data); |
145 | return data; | 147 | return data; |
146 | } | 148 | } |
147 | 149 | ||
@@ -157,7 +159,7 @@ export default class ServerApi { | |||
157 | 159 | ||
158 | let services = await this._mapServiceModels(data); | 160 | let services = await this._mapServiceModels(data); |
159 | services = services.filter(service => service !== null); | 161 | services = services.filter(service => service !== null); |
160 | console.debug('ServerApi::getServices resolves', services); | 162 | debug('ServerApi::getServices resolves', services); |
161 | return services; | 163 | return services; |
162 | } | 164 | } |
163 | 165 | ||
@@ -181,7 +183,7 @@ export default class ServerApi { | |||
181 | 183 | ||
182 | const service = Object.assign(serviceData, { data: await this._prepareServiceModel(serviceData.data) }); | 184 | const service = Object.assign(serviceData, { data: await this._prepareServiceModel(serviceData.data) }); |
183 | 185 | ||
184 | console.debug('ServerApi::createService resolves', service); | 186 | debug('ServerApi::createService resolves', service); |
185 | return service; | 187 | return service; |
186 | } | 188 | } |
187 | 189 | ||
@@ -205,7 +207,7 @@ export default class ServerApi { | |||
205 | 207 | ||
206 | const service = Object.assign(serviceData, { data: await this._prepareServiceModel(serviceData.data) }); | 208 | const service = Object.assign(serviceData, { data: await this._prepareServiceModel(serviceData.data) }); |
207 | 209 | ||
208 | console.debug('ServerApi::updateService resolves', service); | 210 | debug('ServerApi::updateService resolves', service); |
209 | return service; | 211 | return service; |
210 | } | 212 | } |
211 | 213 | ||
@@ -240,7 +242,7 @@ export default class ServerApi { | |||
240 | throw request; | 242 | throw request; |
241 | } | 243 | } |
242 | const serviceData = await request.json(); | 244 | const serviceData = await request.json(); |
243 | console.debug('ServerApi::reorderService resolves', serviceData); | 245 | debug('ServerApi::reorderService resolves', serviceData); |
244 | return serviceData; | 246 | return serviceData; |
245 | } | 247 | } |
246 | 248 | ||
@@ -255,7 +257,7 @@ export default class ServerApi { | |||
255 | 257 | ||
256 | removeServicePartitionDirectory(id, true); | 258 | removeServicePartitionDirectory(id, true); |
257 | 259 | ||
258 | console.debug('ServerApi::deleteService resolves', data); | 260 | debug('ServerApi::deleteService resolves', data); |
259 | return data; | 261 | return data; |
260 | } | 262 | } |
261 | 263 | ||
@@ -277,7 +279,7 @@ export default class ServerApi { | |||
277 | 279 | ||
278 | this.recipes = this.recipes.concat(this._getDevRecipes()); | 280 | this.recipes = this.recipes.concat(this._getDevRecipes()); |
279 | 281 | ||
280 | console.debug('StubServerApi::getInstalledRecipes resolves', this.recipes); | 282 | debug('StubServerApi::getInstalledRecipes resolves', this.recipes); |
281 | return this.recipes; | 283 | return this.recipes; |
282 | } | 284 | } |
283 | 285 | ||
@@ -290,7 +292,7 @@ export default class ServerApi { | |||
290 | throw request; | 292 | throw request; |
291 | } | 293 | } |
292 | const recipes = await request.json(); | 294 | const recipes = await request.json(); |
293 | console.debug('ServerApi::getRecipeUpdates resolves', recipes); | 295 | debug('ServerApi::getRecipeUpdates resolves', recipes); |
294 | return recipes; | 296 | return recipes; |
295 | } | 297 | } |
296 | 298 | ||
@@ -305,7 +307,7 @@ export default class ServerApi { | |||
305 | const data = await request.json(); | 307 | const data = await request.json(); |
306 | 308 | ||
307 | const recipePreviews = this._mapRecipePreviewModel(data); | 309 | const recipePreviews = this._mapRecipePreviewModel(data); |
308 | console.debug('ServerApi::getRecipes resolves', recipePreviews); | 310 | debug('ServerApi::getRecipes resolves', recipePreviews); |
309 | 311 | ||
310 | return recipePreviews; | 312 | return recipePreviews; |
311 | } | 313 | } |
@@ -322,7 +324,7 @@ export default class ServerApi { | |||
322 | // data = this._addLocalRecipesToPreviews(data); | 324 | // data = this._addLocalRecipesToPreviews(data); |
323 | 325 | ||
324 | const recipePreviews = this._mapRecipePreviewModel(data); | 326 | const recipePreviews = this._mapRecipePreviewModel(data); |
325 | console.debug('ServerApi::getFeaturedRecipes resolves', recipePreviews); | 327 | debug('ServerApi::getFeaturedRecipes resolves', recipePreviews); |
326 | return recipePreviews; | 328 | return recipePreviews; |
327 | } | 329 | } |
328 | 330 | ||
@@ -336,7 +338,7 @@ export default class ServerApi { | |||
336 | const data = await request.json(); | 338 | const data = await request.json(); |
337 | 339 | ||
338 | const recipePreviews = this._mapRecipePreviewModel(data); | 340 | const recipePreviews = this._mapRecipePreviewModel(data); |
339 | console.debug('ServerApi::searchRecipePreviews resolves', recipePreviews); | 341 | debug('ServerApi::searchRecipePreviews resolves', recipePreviews); |
340 | return recipePreviews; | 342 | return recipePreviews; |
341 | } | 343 | } |
342 | 344 | ||
@@ -350,7 +352,7 @@ export default class ServerApi { | |||
350 | 352 | ||
351 | fs.ensureDirSync(recipeTempDirectory); | 353 | fs.ensureDirSync(recipeTempDirectory); |
352 | const res = await fetch(packageUrl); | 354 | const res = await fetch(packageUrl); |
353 | console.debug('Recipe downloaded', recipeId); | 355 | debug('Recipe downloaded', recipeId); |
354 | const buffer = await res.buffer(); | 356 | const buffer = await res.buffer(); |
355 | fs.writeFileSync(archivePath, buffer); | 357 | fs.writeFileSync(archivePath, buffer); |
356 | 358 | ||
@@ -392,7 +394,7 @@ export default class ServerApi { | |||
392 | const data = await request.json(); | 394 | const data = await request.json(); |
393 | 395 | ||
394 | const plan = new PlanModel(data); | 396 | const plan = new PlanModel(data); |
395 | console.debug('ServerApi::getPlans resolves', plan); | 397 | debug('ServerApi::getPlans resolves', plan); |
396 | return plan; | 398 | return plan; |
397 | } | 399 | } |
398 | 400 | ||
@@ -408,7 +410,7 @@ export default class ServerApi { | |||
408 | } | 410 | } |
409 | const data = await request.json(); | 411 | const data = await request.json(); |
410 | 412 | ||
411 | console.debug('ServerApi::getHostedPage resolves', data); | 413 | debug('ServerApi::getHostedPage resolves', data); |
412 | return data; | 414 | return data; |
413 | } | 415 | } |
414 | 416 | ||
@@ -421,7 +423,7 @@ export default class ServerApi { | |||
421 | } | 423 | } |
422 | const data = await request.json(); | 424 | const data = await request.json(); |
423 | 425 | ||
424 | console.debug('ServerApi::getPaymentDashboardUrl resolves', data); | 426 | debug('ServerApi::getPaymentDashboardUrl resolves', data); |
425 | return data; | 427 | return data; |
426 | } | 428 | } |
427 | 429 | ||
@@ -434,7 +436,7 @@ export default class ServerApi { | |||
434 | } | 436 | } |
435 | const data = await request.json(); | 437 | const data = await request.json(); |
436 | const orders = this._mapOrderModels(data); | 438 | const orders = this._mapOrderModels(data); |
437 | console.debug('ServerApi::getSubscriptionOrders resolves', orders); | 439 | debug('ServerApi::getSubscriptionOrders resolves', orders); |
438 | return orders; | 440 | return orders; |
439 | } | 441 | } |
440 | 442 | ||
@@ -451,7 +453,7 @@ export default class ServerApi { | |||
451 | } | 453 | } |
452 | const data = await request.json(); | 454 | const data = await request.json(); |
453 | const news = this._mapNewsModels(data); | 455 | const news = this._mapNewsModels(data); |
454 | console.debug('ServerApi::getLatestNews resolves', news); | 456 | debug('ServerApi::getLatestNews resolves', news); |
455 | return news; | 457 | return news; |
456 | } | 458 | } |
457 | 459 | ||
@@ -465,7 +467,7 @@ export default class ServerApi { | |||
465 | throw request; | 467 | throw request; |
466 | } | 468 | } |
467 | 469 | ||
468 | console.debug('ServerApi::hideNews resolves', id); | 470 | debug('ServerApi::hideNews resolves', id); |
469 | } | 471 | } |
470 | 472 | ||
471 | // Health Check | 473 | // Health Check |
@@ -476,7 +478,7 @@ export default class ServerApi { | |||
476 | if (!request.ok) { | 478 | if (!request.ok) { |
477 | throw request; | 479 | throw request; |
478 | } | 480 | } |
479 | console.debug('ServerApi::healthCheck resolves'); | 481 | debug('ServerApi::healthCheck resolves'); |
480 | } | 482 | } |
481 | 483 | ||
482 | async getLegacyServices() { | 484 | async getLegacyServices() { |
@@ -502,7 +504,7 @@ export default class ServerApi { | |||
502 | return service; | 504 | return service; |
503 | })); | 505 | })); |
504 | 506 | ||
505 | console.debug('ServerApi::getLegacyServices resolves', services); | 507 | debug('ServerApi::getLegacyServices resolves', services); |
506 | return services; | 508 | return services; |
507 | } | 509 | } |
508 | } catch (err) { | 510 | } catch (err) { |
@@ -535,7 +537,7 @@ export default class ServerApi { | |||
535 | 537 | ||
536 | return new ServiceModel(service, recipe); | 538 | return new ServiceModel(service, recipe); |
537 | } catch (e) { | 539 | } catch (e) { |
538 | console.debug(e); | 540 | debug(e); |
539 | return null; | 541 | return null; |
540 | } | 542 | } |
541 | } | 543 | } |
@@ -553,7 +555,7 @@ export default class ServerApi { | |||
553 | 555 | ||
554 | await this.getRecipePackage(recipeId); | 556 | await this.getRecipePackage(recipeId); |
555 | 557 | ||
556 | console.debug('Rerun ServerAPI::getInstalledRecipes'); | 558 | debug('Rerun ServerAPI::getInstalledRecipes'); |
557 | await this.getInstalledRecipes(); | 559 | await this.getInstalledRecipes(); |
558 | 560 | ||
559 | recipe = this.recipes.find(r => r.id === recipeId); | 561 | recipe = this.recipes.find(r => r.id === recipeId); |
@@ -653,7 +655,7 @@ export default class ServerApi { | |||
653 | 655 | ||
654 | return recipes; | 656 | return recipes; |
655 | } catch (err) { | 657 | } catch (err) { |
656 | console.debug('Could not load dev recipes'); | 658 | debug('Could not load dev recipes'); |
657 | return false; | 659 | return false; |
658 | } | 660 | } |
659 | } | 661 | } |