diff options
author | Chocobozzz <me@florianbigard.com> | 2022-07-15 15:30:14 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-07-18 11:37:18 +0200 |
commit | 42b40636991b97fe818007fab19091764fc5db73 (patch) | |
tree | db431787c06ce898d22e91ff771f795219274fc6 /client/src/app/core/rest | |
parent | 654d4ede7fa4d0faa71e49bcfab6b65a686397b2 (diff) | |
download | PeerTube-42b40636991b97fe818007fab19091764fc5db73.tar.gz PeerTube-42b40636991b97fe818007fab19091764fc5db73.tar.zst PeerTube-42b40636991b97fe818007fab19091764fc5db73.zip |
Add ability for client to create server logs
Diffstat (limited to 'client/src/app/core/rest')
-rw-r--r-- | client/src/app/core/rest/rest-extractor.service.ts | 7 | ||||
-rw-r--r-- | client/src/app/core/rest/rest-table.ts | 9 | ||||
-rw-r--r-- | client/src/app/core/rest/rest.service.ts | 6 |
3 files changed, 12 insertions, 10 deletions
diff --git a/client/src/app/core/rest/rest-extractor.service.ts b/client/src/app/core/rest/rest-extractor.service.ts index 86c7484a5..8a2974563 100644 --- a/client/src/app/core/rest/rest-extractor.service.ts +++ b/client/src/app/core/rest/rest-extractor.service.ts | |||
@@ -3,6 +3,7 @@ import { Injectable } from '@angular/core' | |||
3 | import { Router } from '@angular/router' | 3 | import { Router } from '@angular/router' |
4 | import { dateToHuman } from '@app/helpers' | 4 | import { dateToHuman } from '@app/helpers' |
5 | import { HttpStatusCode, ResultList } from '@shared/models' | 5 | import { HttpStatusCode, ResultList } from '@shared/models' |
6 | import { logger } from '@root-helpers/logger' | ||
6 | 7 | ||
7 | @Injectable() | 8 | @Injectable() |
8 | export class RestExtractor { | 9 | export class RestExtractor { |
@@ -64,7 +65,7 @@ export class RestExtractor { | |||
64 | if (err.error instanceof Error) { | 65 | if (err.error instanceof Error) { |
65 | // A client-side or network error occurred. Handle it accordingly. | 66 | // A client-side or network error occurred. Handle it accordingly. |
66 | const errorMessage = err.error.detail || err.error.title | 67 | const errorMessage = err.error.detail || err.error.title |
67 | console.error('An error occurred:', errorMessage) | 68 | logger.error('An error occurred:', errorMessage) |
68 | 69 | ||
69 | return errorMessage | 70 | return errorMessage |
70 | } | 71 | } |
@@ -75,12 +76,12 @@ export class RestExtractor { | |||
75 | 76 | ||
76 | if (err.status !== undefined) { | 77 | if (err.status !== undefined) { |
77 | const errorMessage = this.buildServerErrorMessage(err) | 78 | const errorMessage = this.buildServerErrorMessage(err) |
78 | console.error(`Backend returned code ${err.status}, errorMessage is: ${errorMessage}`) | 79 | logger.error(`Backend returned code ${err.status}, errorMessage is: ${errorMessage}`) |
79 | 80 | ||
80 | return errorMessage | 81 | return errorMessage |
81 | } | 82 | } |
82 | 83 | ||
83 | console.error(err) | 84 | logger.error(err) |
84 | return err | 85 | return err |
85 | } | 86 | } |
86 | 87 | ||
diff --git a/client/src/app/core/rest/rest-table.ts b/client/src/app/core/rest/rest-table.ts index cb5bd0b89..ec5646b5d 100644 --- a/client/src/app/core/rest/rest-table.ts +++ b/client/src/app/core/rest/rest-table.ts | |||
@@ -1,10 +1,11 @@ | |||
1 | import * as debug from 'debug' | 1 | import debug from 'debug' |
2 | import { LazyLoadEvent, SortMeta } from 'primeng/api' | 2 | import { LazyLoadEvent, SortMeta } from 'primeng/api' |
3 | import { ActivatedRoute, Router } from '@angular/router' | 3 | import { ActivatedRoute, Router } from '@angular/router' |
4 | import { logger } from '@root-helpers/logger' | ||
4 | import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' | 5 | import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' |
5 | import { RestPagination } from './rest-pagination' | 6 | import { RestPagination } from './rest-pagination' |
6 | 7 | ||
7 | const logger = debug('peertube:tables:RestTable') | 8 | const debugLogger = debug('peertube:tables:RestTable') |
8 | 9 | ||
9 | export abstract class RestTable { | 10 | export abstract class RestTable { |
10 | 11 | ||
@@ -34,7 +35,7 @@ export abstract class RestTable { | |||
34 | try { | 35 | try { |
35 | this.sort = JSON.parse(result) | 36 | this.sort = JSON.parse(result) |
36 | } catch (err) { | 37 | } catch (err) { |
37 | console.error('Cannot load sort of local storage key ' + this.getSortLocalStorageKey(), err) | 38 | logger.error('Cannot load sort of local storage key ' + this.getSortLocalStorageKey(), err) |
38 | } | 39 | } |
39 | } | 40 | } |
40 | } | 41 | } |
@@ -44,7 +45,7 @@ export abstract class RestTable { | |||
44 | } | 45 | } |
45 | 46 | ||
46 | loadLazy (event: LazyLoadEvent) { | 47 | loadLazy (event: LazyLoadEvent) { |
47 | logger('Load lazy %o.', event) | 48 | debugLogger('Load lazy %o.', event) |
48 | 49 | ||
49 | this.sort = { | 50 | this.sort = { |
50 | order: event.sortOrder, | 51 | order: event.sortOrder, |
diff --git a/client/src/app/core/rest/rest.service.ts b/client/src/app/core/rest/rest.service.ts index fc729f0f6..d8b5ffb18 100644 --- a/client/src/app/core/rest/rest.service.ts +++ b/client/src/app/core/rest/rest.service.ts | |||
@@ -5,7 +5,7 @@ import { Injectable } from '@angular/core' | |||
5 | import { ComponentPaginationLight } from './component-pagination.model' | 5 | import { ComponentPaginationLight } from './component-pagination.model' |
6 | import { RestPagination } from './rest-pagination' | 6 | import { RestPagination } from './rest-pagination' |
7 | 7 | ||
8 | const logger = debug('peertube:rest') | 8 | const debugLogger = debug('peertube:rest') |
9 | 9 | ||
10 | interface QueryStringFilterPrefixes { | 10 | interface QueryStringFilterPrefixes { |
11 | [key: string]: { | 11 | [key: string]: { |
@@ -88,7 +88,7 @@ export class RestService { | |||
88 | const prefixeStrings = Object.values(prefixes) | 88 | const prefixeStrings = Object.values(prefixes) |
89 | .map(p => p.prefix) | 89 | .map(p => p.prefix) |
90 | 90 | ||
91 | logger(`Built tokens "${tokens.join(', ')}" for prefixes "${prefixeStrings.join(', ')}"`) | 91 | debugLogger(`Built tokens "${tokens.join(', ')}" for prefixes "${prefixeStrings.join(', ')}"`) |
92 | 92 | ||
93 | // Search is the querystring minus defined filters | 93 | // Search is the querystring minus defined filters |
94 | const searchTokens = tokens.filter(t => { | 94 | const searchTokens = tokens.filter(t => { |
@@ -127,7 +127,7 @@ export class RestService { | |||
127 | 127 | ||
128 | const search = searchTokens.join(' ') || undefined | 128 | const search = searchTokens.join(' ') || undefined |
129 | 129 | ||
130 | logger('Built search: ' + search, additionalFilters) | 130 | debugLogger('Built search: ' + search, additionalFilters) |
131 | 131 | ||
132 | return { | 132 | return { |
133 | search, | 133 | search, |