aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/core/rest
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-07-15 15:30:14 +0200
committerChocobozzz <me@florianbigard.com>2022-07-18 11:37:18 +0200
commit42b40636991b97fe818007fab19091764fc5db73 (patch)
treedb431787c06ce898d22e91ff771f795219274fc6 /client/src/app/core/rest
parent654d4ede7fa4d0faa71e49bcfab6b65a686397b2 (diff)
downloadPeerTube-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.ts7
-rw-r--r--client/src/app/core/rest/rest-table.ts9
-rw-r--r--client/src/app/core/rest/rest.service.ts6
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'
3import { Router } from '@angular/router' 3import { Router } from '@angular/router'
4import { dateToHuman } from '@app/helpers' 4import { dateToHuman } from '@app/helpers'
5import { HttpStatusCode, ResultList } from '@shared/models' 5import { HttpStatusCode, ResultList } from '@shared/models'
6import { logger } from '@root-helpers/logger'
6 7
7@Injectable() 8@Injectable()
8export class RestExtractor { 9export 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 @@
1import * as debug from 'debug' 1import debug from 'debug'
2import { LazyLoadEvent, SortMeta } from 'primeng/api' 2import { LazyLoadEvent, SortMeta } from 'primeng/api'
3import { ActivatedRoute, Router } from '@angular/router' 3import { ActivatedRoute, Router } from '@angular/router'
4import { logger } from '@root-helpers/logger'
4import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' 5import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
5import { RestPagination } from './rest-pagination' 6import { RestPagination } from './rest-pagination'
6 7
7const logger = debug('peertube:tables:RestTable') 8const debugLogger = debug('peertube:tables:RestTable')
8 9
9export abstract class RestTable { 10export 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'
5import { ComponentPaginationLight } from './component-pagination.model' 5import { ComponentPaginationLight } from './component-pagination.model'
6import { RestPagination } from './rest-pagination' 6import { RestPagination } from './rest-pagination'
7 7
8const logger = debug('peertube:rest') 8const debugLogger = debug('peertube:rest')
9 9
10interface QueryStringFilterPrefixes { 10interface 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,