improve logging
This commit is contained in:
@ -12,7 +12,7 @@ export const log = {
|
|||||||
console.debug(new Date().toISOString(), ...params);
|
console.debug(new Date().toISOString(), ...params);
|
||||||
},
|
},
|
||||||
debug: (...params: any[]) => {
|
debug: (...params: any[]) => {
|
||||||
if (!DEV) {
|
if (!log.isDebugEnabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.debug(new Date().toISOString(), ...params);
|
console.debug(new Date().toISOString(), ...params);
|
||||||
@ -28,5 +28,8 @@ export const log = {
|
|||||||
},
|
},
|
||||||
error: (...params: any[]) => {
|
error: (...params: any[]) => {
|
||||||
console.error(new Date().toISOString(), ...params);
|
console.error(new Date().toISOString(), ...params);
|
||||||
|
},
|
||||||
|
isDebugEnabled: (): boolean => {
|
||||||
|
return DEV;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -141,7 +141,7 @@ export class YoutubePlaylistAdder {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!song.youtubeUrl) {
|
if (!song.youtubeUrl) {
|
||||||
log.debug('Skip adding song to YT playlist, no youtube Url', song);
|
log.info('Skip adding song to YT playlist, no youtube Url', song);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +186,11 @@ export class YoutubePlaylistAdder {
|
|||||||
const youtubeApiUrl = new URL(`${this.apiBase}/playlistItems?${searchParams}`);
|
const youtubeApiUrl = new URL(`${this.apiBase}/playlistItems?${searchParams}`);
|
||||||
const resp = await fetch(youtubeApiUrl, options);
|
const resp = await fetch(youtubeApiUrl, options);
|
||||||
const respObj = await resp.json();
|
const respObj = await resp.json();
|
||||||
log.debug('Added to playlist', options, respObj);
|
if (log.isDebugEnabled()) {
|
||||||
|
log.info('Added to playlist', options, respObj);
|
||||||
|
} else {
|
||||||
|
log.info('Added to playlist', youtubeId, song.title);
|
||||||
|
}
|
||||||
if (respObj.error) {
|
if (respObj.error) {
|
||||||
log.debug('Add to playlist failed', respObj.error.errors);
|
log.debug('Add to playlist failed', respObj.error.errors);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user