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 | |
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')
-rw-r--r-- | client/src/app/core/auth/auth.service.ts | 12 | ||||
-rw-r--r-- | client/src/app/core/notification/notifier.service.ts | 7 | ||||
-rw-r--r-- | client/src/app/core/plugins/hooks.service.ts | 3 | ||||
-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 | ||||
-rw-r--r-- | client/src/app/core/routing/custom-reuse-strategy.ts | 7 | ||||
-rw-r--r-- | client/src/app/core/routing/redirect.service.ts | 23 | ||||
-rw-r--r-- | client/src/app/core/routing/scroll.service.ts | 9 | ||||
-rw-r--r-- | client/src/app/core/server/server.service.ts | 3 | ||||
-rw-r--r-- | client/src/app/core/theme/theme.service.ts | 11 | ||||
-rw-r--r-- | client/src/app/core/users/user-local-storage.service.ts | 7 |
12 files changed, 55 insertions, 49 deletions
diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts index 2ac88c185..ece6bc5d1 100644 --- a/client/src/app/core/auth/auth.service.ts +++ b/client/src/app/core/auth/auth.service.ts | |||
@@ -5,7 +5,7 @@ import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http' | |||
5 | import { Injectable } from '@angular/core' | 5 | import { Injectable } from '@angular/core' |
6 | import { Router } from '@angular/router' | 6 | import { Router } from '@angular/router' |
7 | import { Notifier } from '@app/core/notification/notifier.service' | 7 | import { Notifier } from '@app/core/notification/notifier.service' |
8 | import { objectToUrlEncoded, peertubeLocalStorage, UserTokens } from '@root-helpers/index' | 8 | import { logger, objectToUrlEncoded, peertubeLocalStorage, UserTokens } from '@root-helpers/index' |
9 | import { HttpStatusCode, MyUser as UserServerModel, OAuthClientLocal, User, UserLogin, UserRefreshToken } from '@shared/models' | 9 | import { HttpStatusCode, MyUser as UserServerModel, OAuthClientLocal, User, UserLogin, UserRefreshToken } from '@shared/models' |
10 | import { environment } from '../../../environments/environment' | 10 | import { environment } from '../../../environments/environment' |
11 | import { RestExtractor } from '../rest/rest-extractor.service' | 11 | import { RestExtractor } from '../rest/rest-extractor.service' |
@@ -90,7 +90,7 @@ export class AuthService { | |||
90 | peertubeLocalStorage.setItem(AuthService.LOCAL_STORAGE_OAUTH_CLIENT_KEYS.CLIENT_ID, this.clientId) | 90 | peertubeLocalStorage.setItem(AuthService.LOCAL_STORAGE_OAUTH_CLIENT_KEYS.CLIENT_ID, this.clientId) |
91 | peertubeLocalStorage.setItem(AuthService.LOCAL_STORAGE_OAUTH_CLIENT_KEYS.CLIENT_SECRET, this.clientSecret) | 91 | peertubeLocalStorage.setItem(AuthService.LOCAL_STORAGE_OAUTH_CLIENT_KEYS.CLIENT_SECRET, this.clientSecret) |
92 | 92 | ||
93 | console.log('Client credentials loaded.') | 93 | logger.info('Client credentials loaded.') |
94 | }, | 94 | }, |
95 | 95 | ||
96 | error: err => { | 96 | error: err => { |
@@ -177,7 +177,7 @@ Ensure you have correctly configured PeerTube (config/ directory), in particular | |||
177 | } | 177 | } |
178 | }, | 178 | }, |
179 | 179 | ||
180 | error: err => console.error(err) | 180 | error: err => logger.error(err) |
181 | }) | 181 | }) |
182 | 182 | ||
183 | this.user = null | 183 | this.user = null |
@@ -190,7 +190,7 @@ Ensure you have correctly configured PeerTube (config/ directory), in particular | |||
190 | refreshAccessToken () { | 190 | refreshAccessToken () { |
191 | if (this.refreshingTokenObservable) return this.refreshingTokenObservable | 191 | if (this.refreshingTokenObservable) return this.refreshingTokenObservable |
192 | 192 | ||
193 | console.log('Refreshing token...') | 193 | logger.info('Refreshing token...') |
194 | 194 | ||
195 | const refreshToken = this.getRefreshToken() | 195 | const refreshToken = this.getRefreshToken() |
196 | 196 | ||
@@ -212,8 +212,8 @@ Ensure you have correctly configured PeerTube (config/ directory), in particular | |||
212 | catchError(err => { | 212 | catchError(err => { |
213 | this.refreshingTokenObservable = null | 213 | this.refreshingTokenObservable = null |
214 | 214 | ||
215 | console.error(err) | 215 | logger.error(err) |
216 | console.log('Cannot refresh token -> logout...') | 216 | logger.info('Cannot refresh token -> logout...') |
217 | this.logout() | 217 | this.logout() |
218 | this.router.navigate([ '/login' ]) | 218 | this.router.navigate([ '/login' ]) |
219 | 219 | ||
diff --git a/client/src/app/core/notification/notifier.service.ts b/client/src/app/core/notification/notifier.service.ts index 165bb0c76..15af5c1b6 100644 --- a/client/src/app/core/notification/notifier.service.ts +++ b/client/src/app/core/notification/notifier.service.ts | |||
@@ -1,5 +1,6 @@ | |||
1 | import { MessageService } from 'primeng/api' | 1 | import { MessageService } from 'primeng/api' |
2 | import { Injectable } from '@angular/core' | 2 | import { Injectable } from '@angular/core' |
3 | import { logger } from '@root-helpers/logger' | ||
3 | 4 | ||
4 | @Injectable() | 5 | @Injectable() |
5 | export class Notifier { | 6 | export class Notifier { |
@@ -10,21 +11,21 @@ export class Notifier { | |||
10 | info (text: string, title?: string, timeout?: number, sticky?: boolean) { | 11 | info (text: string, title?: string, timeout?: number, sticky?: boolean) { |
11 | if (!title) title = $localize`Info` | 12 | if (!title) title = $localize`Info` |
12 | 13 | ||
13 | console.info(`${title}: ${text}`) | 14 | logger.info(`${title}: ${text}`) |
14 | return this.notify('info', text, title, timeout, sticky) | 15 | return this.notify('info', text, title, timeout, sticky) |
15 | } | 16 | } |
16 | 17 | ||
17 | error (text: string, title?: string, timeout?: number, sticky?: boolean) { | 18 | error (text: string, title?: string, timeout?: number, sticky?: boolean) { |
18 | if (!title) title = $localize`Error` | 19 | if (!title) title = $localize`Error` |
19 | 20 | ||
20 | console.error(`${title}: ${text}`) | 21 | logger.error(`${title}: ${text}`) |
21 | return this.notify('error', text, title, timeout, sticky) | 22 | return this.notify('error', text, title, timeout, sticky) |
22 | } | 23 | } |
23 | 24 | ||
24 | success (text: string, title?: string, timeout?: number, sticky?: boolean) { | 25 | success (text: string, title?: string, timeout?: number, sticky?: boolean) { |
25 | if (!title) title = $localize`Success` | 26 | if (!title) title = $localize`Success` |
26 | 27 | ||
27 | console.log(`${title}: ${text}`) | 28 | logger.info(`${title}: ${text}`) |
28 | return this.notify('success', text, title, timeout, sticky) | 29 | return this.notify('success', text, title, timeout, sticky) |
29 | } | 30 | } |
30 | 31 | ||
diff --git a/client/src/app/core/plugins/hooks.service.ts b/client/src/app/core/plugins/hooks.service.ts index 062083fd1..7fd56d92e 100644 --- a/client/src/app/core/plugins/hooks.service.ts +++ b/client/src/app/core/plugins/hooks.service.ts | |||
@@ -2,6 +2,7 @@ import { from, Observable } from 'rxjs' | |||
2 | import { mergeMap, switchMap } from 'rxjs/operators' | 2 | import { mergeMap, switchMap } from 'rxjs/operators' |
3 | import { Injectable } from '@angular/core' | 3 | import { Injectable } from '@angular/core' |
4 | import { PluginService } from '@app/core/plugins/plugin.service' | 4 | import { PluginService } from '@app/core/plugins/plugin.service' |
5 | import { logger } from '@root-helpers/logger' | ||
5 | import { ClientActionHookName, ClientFilterHookName, PluginClientScope } from '@shared/models' | 6 | import { ClientActionHookName, ClientFilterHookName, PluginClientScope } from '@shared/models' |
6 | import { AuthService, AuthStatus } from '../auth' | 7 | import { AuthService, AuthStatus } from '../auth' |
7 | 8 | ||
@@ -50,7 +51,7 @@ export class HooksService { | |||
50 | runAction<T, U extends ClientActionHookName> (hookName: U, scope: PluginClientScope, params?: T) { | 51 | runAction<T, U extends ClientActionHookName> (hookName: U, scope: PluginClientScope, params?: T) { |
51 | this.pluginService.ensurePluginsAreLoaded(scope) | 52 | this.pluginService.ensurePluginsAreLoaded(scope) |
52 | .then(() => this.pluginService.runHook(hookName, undefined, params)) | 53 | .then(() => this.pluginService.runHook(hookName, undefined, params)) |
53 | .catch((err: any) => console.error('Fatal hook error.', { err })) | 54 | .catch((err: any) => logger.error('Fatal hook error.', err)) |
54 | } | 55 | } |
55 | 56 | ||
56 | async wrapObject<T, U extends ClientFilterHookName> (result: T, scope: PluginClientScope, hookName: U) { | 57 | async wrapObject<T, U extends ClientFilterHookName> (result: T, scope: PluginClientScope, hookName: U) { |
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, |
diff --git a/client/src/app/core/routing/custom-reuse-strategy.ts b/client/src/app/core/routing/custom-reuse-strategy.ts index 5d3ad2e67..269b9d193 100644 --- a/client/src/app/core/routing/custom-reuse-strategy.ts +++ b/client/src/app/core/routing/custom-reuse-strategy.ts | |||
@@ -1,5 +1,6 @@ | |||
1 | import { ComponentRef, Injectable } from '@angular/core' | 1 | import { ComponentRef, Injectable } from '@angular/core' |
2 | import { ActivatedRouteSnapshot, DetachedRouteHandle, RouteReuseStrategy } from '@angular/router' | 2 | import { ActivatedRouteSnapshot, DetachedRouteHandle, RouteReuseStrategy } from '@angular/router' |
3 | import { logger } from '@root-helpers/logger' | ||
3 | import { DisableForReuseHook } from './disable-for-reuse-hook' | 4 | import { DisableForReuseHook } from './disable-for-reuse-hook' |
4 | import { PeerTubeRouterService, RouterSetting } from './peertube-router.service' | 5 | import { PeerTubeRouterService, RouterSetting } from './peertube-router.service' |
5 | 6 | ||
@@ -22,7 +23,7 @@ export class CustomReuseStrategy implements RouteReuseStrategy { | |||
22 | const key = this.generateKey(route) | 23 | const key = this.generateKey(route) |
23 | this.recentlyUsed = key | 24 | this.recentlyUsed = key |
24 | 25 | ||
25 | console.log('Storing component %s to reuse later.', key) | 26 | logger.info(`Storing component ${key} to reuse later.`) |
26 | 27 | ||
27 | const componentRef = (handle as any).componentRef as ComponentRef<DisableForReuseHook> | 28 | const componentRef = (handle as any).componentRef as ComponentRef<DisableForReuseHook> |
28 | componentRef.instance.disableForReuse() | 29 | componentRef.instance.disableForReuse() |
@@ -46,7 +47,7 @@ export class CustomReuseStrategy implements RouteReuseStrategy { | |||
46 | const key = this.generateKey(route) | 47 | const key = this.generateKey(route) |
47 | this.recentlyUsed = key | 48 | this.recentlyUsed = key |
48 | 49 | ||
49 | console.log('Reusing component %s.', key) | 50 | logger.info(`Reusing component ${key}.`) |
50 | 51 | ||
51 | const handle = this.storedRouteHandles.get(key) | 52 | const handle = this.storedRouteHandles.get(key) |
52 | if (!handle) return handle; | 53 | if (!handle) return handle; |
@@ -66,7 +67,7 @@ export class CustomReuseStrategy implements RouteReuseStrategy { | |||
66 | this.storedRouteHandles.forEach((r, key) => { | 67 | this.storedRouteHandles.forEach((r, key) => { |
67 | if (key === this.recentlyUsed) return | 68 | if (key === this.recentlyUsed) return |
68 | 69 | ||
69 | console.log('Removing stored component %s.', key); | 70 | logger.info(`Removing stored component ${key}`); |
70 | 71 | ||
71 | (r as any).componentRef.destroy() | 72 | (r as any).componentRef.destroy() |
72 | this.storedRouteHandles.delete(key) | 73 | this.storedRouteHandles.delete(key) |
diff --git a/client/src/app/core/routing/redirect.service.ts b/client/src/app/core/routing/redirect.service.ts index 567fd432b..575b3b2a1 100644 --- a/client/src/app/core/routing/redirect.service.ts +++ b/client/src/app/core/routing/redirect.service.ts | |||
@@ -1,10 +1,11 @@ | |||
1 | import * as debug from 'debug' | 1 | import * as debug from 'debug' |
2 | import { Injectable } from '@angular/core' | 2 | import { Injectable } from '@angular/core' |
3 | import { NavigationCancel, NavigationEnd, Router } from '@angular/router' | 3 | import { NavigationCancel, NavigationEnd, Router } from '@angular/router' |
4 | import { logger } from '@root-helpers/logger' | ||
4 | import { ServerService } from '../server' | 5 | import { ServerService } from '../server' |
5 | import { SessionStorageService } from '../wrappers/storage.service' | 6 | import { SessionStorageService } from '../wrappers/storage.service' |
6 | 7 | ||
7 | const logger = debug('peertube:router:RedirectService') | 8 | const debugLogger = debug('peertube:router:RedirectService') |
8 | 9 | ||
9 | @Injectable() | 10 | @Injectable() |
10 | export class RedirectService { | 11 | export class RedirectService { |
@@ -40,7 +41,7 @@ export class RedirectService { | |||
40 | this.latestSessionUrl = this.storage.getItem(RedirectService.SESSION_STORAGE_LATEST_SESSION_URL_KEY) | 41 | this.latestSessionUrl = this.storage.getItem(RedirectService.SESSION_STORAGE_LATEST_SESSION_URL_KEY) |
41 | this.storage.removeItem(RedirectService.SESSION_STORAGE_LATEST_SESSION_URL_KEY) | 42 | this.storage.removeItem(RedirectService.SESSION_STORAGE_LATEST_SESSION_URL_KEY) |
42 | 43 | ||
43 | logger('Loaded latest session URL %s', this.latestSessionUrl) | 44 | debugLogger('Loaded latest session URL %s', this.latestSessionUrl) |
44 | 45 | ||
45 | // Track previous url | 46 | // Track previous url |
46 | this.currentUrl = this.router.url | 47 | this.currentUrl = this.router.url |
@@ -51,8 +52,8 @@ export class RedirectService { | |||
51 | this.previousUrl = this.currentUrl | 52 | this.previousUrl = this.currentUrl |
52 | this.currentUrl = event.url | 53 | this.currentUrl = event.url |
53 | 54 | ||
54 | logger('Previous URL is %s, current URL is %s', this.previousUrl, this.currentUrl) | 55 | debugLogger('Previous URL is %s, current URL is %s', this.previousUrl, this.currentUrl) |
55 | logger('Setting %s as latest URL in session storage.', this.currentUrl) | 56 | debugLogger('Setting %s as latest URL in session storage.', this.currentUrl) |
56 | 57 | ||
57 | this.storage.setItem(RedirectService.SESSION_STORAGE_LATEST_SESSION_URL_KEY, this.currentUrl) | 58 | this.storage.setItem(RedirectService.SESSION_STORAGE_LATEST_SESSION_URL_KEY, this.currentUrl) |
58 | } | 59 | } |
@@ -84,18 +85,14 @@ export class RedirectService { | |||
84 | 85 | ||
85 | this.redirectingToHomepage = true | 86 | this.redirectingToHomepage = true |
86 | 87 | ||
87 | console.log('Redirecting to %s...', this.defaultRoute) | 88 | logger.info(`Redirecting to ${this.defaultRoute}...`) |
88 | 89 | ||
89 | this.router.navigateByUrl(this.defaultRoute, { skipLocationChange }) | 90 | this.router.navigateByUrl(this.defaultRoute, { skipLocationChange }) |
90 | .then(() => this.redirectingToHomepage = false) | 91 | .then(() => this.redirectingToHomepage = false) |
91 | .catch(() => { | 92 | .catch(() => { |
92 | this.redirectingToHomepage = false | 93 | this.redirectingToHomepage = false |
93 | 94 | ||
94 | console.error( | 95 | logger.error(`Cannot navigate to ${this.defaultRoute}, resetting default route to ${RedirectService.INIT_DEFAULT_ROUTE}`) |
95 | 'Cannot navigate to %s, resetting default route to %s.', | ||
96 | this.defaultRoute, | ||
97 | RedirectService.INIT_DEFAULT_ROUTE | ||
98 | ) | ||
99 | 96 | ||
100 | this.defaultRoute = RedirectService.INIT_DEFAULT_ROUTE | 97 | this.defaultRoute = RedirectService.INIT_DEFAULT_ROUTE |
101 | return this.router.navigateByUrl(this.defaultRoute, { skipLocationChange }) | 98 | return this.router.navigateByUrl(this.defaultRoute, { skipLocationChange }) |
@@ -104,18 +101,18 @@ export class RedirectService { | |||
104 | } | 101 | } |
105 | 102 | ||
106 | private doRedirect (redirectUrl: string, fallbackRoute?: string) { | 103 | private doRedirect (redirectUrl: string, fallbackRoute?: string) { |
107 | logger('Redirecting on %s', redirectUrl) | 104 | debugLogger('Redirecting on %s', redirectUrl) |
108 | 105 | ||
109 | if (this.isValidRedirection(redirectUrl)) { | 106 | if (this.isValidRedirection(redirectUrl)) { |
110 | return this.router.navigateByUrl(redirectUrl) | 107 | return this.router.navigateByUrl(redirectUrl) |
111 | } | 108 | } |
112 | 109 | ||
113 | logger('%s is not a valid redirection, try fallback route %s', redirectUrl, fallbackRoute) | 110 | debugLogger('%s is not a valid redirection, try fallback route %s', redirectUrl, fallbackRoute) |
114 | if (fallbackRoute) { | 111 | if (fallbackRoute) { |
115 | return this.router.navigateByUrl(fallbackRoute) | 112 | return this.router.navigateByUrl(fallbackRoute) |
116 | } | 113 | } |
117 | 114 | ||
118 | logger('There was no fallback route, redirecting to homepage') | 115 | debugLogger('There was no fallback route, redirecting to homepage') |
119 | return this.redirectToHomepage() | 116 | return this.redirectToHomepage() |
120 | } | 117 | } |
121 | 118 | ||
diff --git a/client/src/app/core/routing/scroll.service.ts b/client/src/app/core/routing/scroll.service.ts index 6d37fde71..0966255b3 100644 --- a/client/src/app/core/routing/scroll.service.ts +++ b/client/src/app/core/routing/scroll.service.ts | |||
@@ -4,8 +4,9 @@ import { ViewportScroller } from '@angular/common' | |||
4 | import { Injectable } from '@angular/core' | 4 | import { Injectable } from '@angular/core' |
5 | import { RouterSetting } from '../' | 5 | import { RouterSetting } from '../' |
6 | import { PeerTubeRouterService } from './peertube-router.service' | 6 | import { PeerTubeRouterService } from './peertube-router.service' |
7 | import { logger } from '@root-helpers/logger' | ||
7 | 8 | ||
8 | const logger = debug('peertube:main:ScrollService') | 9 | const debugLogger = debug('peertube:main:ScrollService') |
9 | 10 | ||
10 | @Injectable() | 11 | @Injectable() |
11 | export class ScrollService { | 12 | export class ScrollService { |
@@ -57,8 +58,8 @@ export class ScrollService { | |||
57 | if (nextSearchParams.toString() !== previousSearchParams.toString()) { | 58 | if (nextSearchParams.toString() !== previousSearchParams.toString()) { |
58 | this.resetScroll = true | 59 | this.resetScroll = true |
59 | } | 60 | } |
60 | } catch (e) { | 61 | } catch (err) { |
61 | console.error('Cannot parse URL to check next scroll.', e) | 62 | logger.error('Cannot parse URL to check next scroll.', err) |
62 | this.resetScroll = true | 63 | this.resetScroll = true |
63 | } | 64 | } |
64 | }) | 65 | }) |
@@ -67,7 +68,7 @@ export class ScrollService { | |||
67 | private consumeScroll () { | 68 | private consumeScroll () { |
68 | // Handle anchors/restore position | 69 | // Handle anchors/restore position |
69 | this.peertubeRouter.getScrollEvents().subscribe(e => { | 70 | this.peertubeRouter.getScrollEvents().subscribe(e => { |
70 | logger('Will schedule scroll after router event %o.', { e, resetScroll: this.resetScroll }) | 71 | debugLogger('Will schedule scroll after router event %o.', { e, resetScroll: this.resetScroll }) |
71 | 72 | ||
72 | // scrollToAnchor first to preserve anchor position when using history navigation | 73 | // scrollToAnchor first to preserve anchor position when using history navigation |
73 | if (e.anchor) { | 74 | if (e.anchor) { |
diff --git a/client/src/app/core/server/server.service.ts b/client/src/app/core/server/server.service.ts index d01942139..9db455cb8 100644 --- a/client/src/app/core/server/server.service.ts +++ b/client/src/app/core/server/server.service.ts | |||
@@ -3,6 +3,7 @@ import { first, map, share, shareReplay, switchMap, tap } from 'rxjs/operators' | |||
3 | import { HttpClient } from '@angular/common/http' | 3 | import { HttpClient } from '@angular/common/http' |
4 | import { Inject, Injectable, LOCALE_ID } from '@angular/core' | 4 | import { Inject, Injectable, LOCALE_ID } from '@angular/core' |
5 | import { getDevLocale, isOnDevLocale, sortBy } from '@app/helpers' | 5 | import { getDevLocale, isOnDevLocale, sortBy } from '@app/helpers' |
6 | import { logger } from '@root-helpers/logger' | ||
6 | import { getCompleteLocale, isDefaultLocale, peertubeTranslate } from '@shared/core-utils/i18n' | 7 | import { getCompleteLocale, isDefaultLocale, peertubeTranslate } from '@shared/core-utils/i18n' |
7 | import { HTMLServerConfig, ServerConfig, ServerStats, VideoConstant } from '@shared/models' | 8 | import { HTMLServerConfig, ServerConfig, ServerStats, VideoConstant } from '@shared/models' |
8 | import { environment } from '../../../environments/environment' | 9 | import { environment } from '../../../environments/environment' |
@@ -43,7 +44,7 @@ export class ServerService { | |||
43 | } catch (err) { | 44 | } catch (err) { |
44 | // Expected in dev mode since we can't inject the config in the HTML | 45 | // Expected in dev mode since we can't inject the config in the HTML |
45 | if (environment.production !== false) { | 46 | if (environment.production !== false) { |
46 | console.error('Cannot load config locally. Fallback to API.') | 47 | logger.error('Cannot load config locally. Fallback to API.') |
47 | } | 48 | } |
48 | 49 | ||
49 | return this.getConfig() | 50 | return this.getConfig() |
diff --git a/client/src/app/core/theme/theme.service.ts b/client/src/app/core/theme/theme.service.ts index 40939ecb8..ead1770ba 100644 --- a/client/src/app/core/theme/theme.service.ts +++ b/client/src/app/core/theme/theme.service.ts | |||
@@ -1,4 +1,5 @@ | |||
1 | import { Injectable } from '@angular/core' | 1 | import { Injectable } from '@angular/core' |
2 | import { logger } from '@root-helpers/logger' | ||
2 | import { capitalizeFirstLetter } from '@root-helpers/string' | 3 | import { capitalizeFirstLetter } from '@root-helpers/string' |
3 | import { UserLocalStorageKeys } from '@root-helpers/users' | 4 | import { UserLocalStorageKeys } from '@root-helpers/users' |
4 | import { HTMLServerConfig, ServerConfigTheme } from '@shared/models' | 5 | import { HTMLServerConfig, ServerConfigTheme } from '@shared/models' |
@@ -57,7 +58,7 @@ export class ThemeService { | |||
57 | private injectThemes (themes: ServerConfigTheme[], fromLocalStorage = false) { | 58 | private injectThemes (themes: ServerConfigTheme[], fromLocalStorage = false) { |
58 | this.themes = themes | 59 | this.themes = themes |
59 | 60 | ||
60 | console.log('Injecting %d themes.', this.themes.length) | 61 | logger.info(`Injecting ${this.themes.length} themes.`) |
61 | 62 | ||
62 | const head = this.getHeadElement() | 63 | const head = this.getHeadElement() |
63 | 64 | ||
@@ -117,13 +118,13 @@ export class ThemeService { | |||
117 | 118 | ||
118 | const currentTheme = this.getCurrentTheme() | 119 | const currentTheme = this.getCurrentTheme() |
119 | 120 | ||
120 | console.log('Enabling %s theme.', currentTheme) | 121 | logger.info(`Enabling ${currentTheme} theme.`) |
121 | 122 | ||
122 | this.loadTheme(currentTheme) | 123 | this.loadTheme(currentTheme) |
123 | 124 | ||
124 | const theme = this.getTheme(currentTheme) | 125 | const theme = this.getTheme(currentTheme) |
125 | if (theme) { | 126 | if (theme) { |
126 | console.log('Adding scripts of theme %s.', currentTheme) | 127 | logger.info(`Adding scripts of theme ${currentTheme}`) |
127 | 128 | ||
128 | this.pluginService.addPlugin(theme, true) | 129 | this.pluginService.addPlugin(theme, true) |
129 | 130 | ||
@@ -165,7 +166,7 @@ export class ThemeService { | |||
165 | this.injectThemes([ lastActiveTheme ], true) | 166 | this.injectThemes([ lastActiveTheme ], true) |
166 | this.updateCurrentTheme() | 167 | this.updateCurrentTheme() |
167 | } catch (err) { | 168 | } catch (err) { |
168 | console.error('Cannot parse last active theme.', err) | 169 | logger.error('Cannot parse last active theme.', err) |
169 | return | 170 | return |
170 | } | 171 | } |
171 | } | 172 | } |
@@ -173,7 +174,7 @@ export class ThemeService { | |||
173 | private removeThemePlugins (themeName: string) { | 174 | private removeThemePlugins (themeName: string) { |
174 | const oldTheme = this.getTheme(themeName) | 175 | const oldTheme = this.getTheme(themeName) |
175 | if (oldTheme) { | 176 | if (oldTheme) { |
176 | console.log('Removing scripts of old theme %s.', themeName) | 177 | logger.info(`Removing scripts of old theme ${themeName}.`) |
177 | this.pluginService.removePlugin(oldTheme) | 178 | this.pluginService.removePlugin(oldTheme) |
178 | } | 179 | } |
179 | } | 180 | } |
diff --git a/client/src/app/core/users/user-local-storage.service.ts b/client/src/app/core/users/user-local-storage.service.ts index d15bf735b..fff649eef 100644 --- a/client/src/app/core/users/user-local-storage.service.ts +++ b/client/src/app/core/users/user-local-storage.service.ts | |||
@@ -2,8 +2,9 @@ | |||
2 | import { filter, throttleTime } from 'rxjs' | 2 | import { filter, throttleTime } from 'rxjs' |
3 | import { Injectable } from '@angular/core' | 3 | import { Injectable } from '@angular/core' |
4 | import { AuthService, AuthStatus } from '@app/core/auth' | 4 | import { AuthService, AuthStatus } from '@app/core/auth' |
5 | import { UserLocalStorageKeys, UserTokens } from '@root-helpers/users' | ||
6 | import { getBoolOrDefault } from '@root-helpers/local-storage-utils' | 5 | import { getBoolOrDefault } from '@root-helpers/local-storage-utils' |
6 | import { logger } from '@root-helpers/logger' | ||
7 | import { UserLocalStorageKeys, UserTokens } from '@root-helpers/users' | ||
7 | import { UserRole, UserUpdateMe } from '@shared/models' | 8 | import { UserRole, UserUpdateMe } from '@shared/models' |
8 | import { NSFWPolicyType } from '@shared/models/videos' | 9 | import { NSFWPolicyType } from '@shared/models/videos' |
9 | import { ServerService } from '../server' | 10 | import { ServerService } from '../server' |
@@ -95,7 +96,7 @@ export class UserLocalStorageService { | |||
95 | : null | 96 | : null |
96 | } catch (err) { | 97 | } catch (err) { |
97 | videoLanguages = null | 98 | videoLanguages = null |
98 | console.error('Cannot parse desired video languages from localStorage.', err) | 99 | logger.error('Cannot parse desired video languages from localStorage.', err) |
99 | } | 100 | } |
100 | 101 | ||
101 | const htmlConfig = this.server.getHTMLConfig() | 102 | const htmlConfig = this.server.getHTMLConfig() |
@@ -142,7 +143,7 @@ export class UserLocalStorageService { | |||
142 | 143 | ||
143 | this.localStorageService.setItem(key, localStorageValue) | 144 | this.localStorageService.setItem(key, localStorageValue) |
144 | } catch (err) { | 145 | } catch (err) { |
145 | console.error(`Cannot set ${key}->${value} in localStorage. Likely due to a value impossible to stringify.`, err) | 146 | logger.error(`Cannot set ${key}->${value} in localStorage. Likely due to a value impossible to stringify.`, err) |
146 | } | 147 | } |
147 | } | 148 | } |
148 | } | 149 | } |