improve logging

This commit is contained in:
2025-07-01 20:23:04 +02:00
parent 317f4d7fba
commit a8b6a309f0
2 changed files with 10 additions and 3 deletions

View File

@ -12,7 +12,7 @@ export const log = {
console.debug(new Date().toISOString(), ...params);
},
debug: (...params: any[]) => {
if (!DEV) {
if (!log.isDebugEnabled()) {
return;
}
console.debug(new Date().toISOString(), ...params);
@ -28,5 +28,8 @@ export const log = {
},
error: (...params: any[]) => {
console.error(new Date().toISOString(), ...params);
},
isDebugEnabled: (): boolean => {
return DEV;
}
};

View File

@ -141,7 +141,7 @@ export class YoutubePlaylistAdder {
return;
}
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;
}
@ -186,7 +186,11 @@ export class YoutubePlaylistAdder {
const youtubeApiUrl = new URL(`${this.apiBase}/playlistItems?${searchParams}`);
const resp = await fetch(youtubeApiUrl, options);
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) {
log.debug('Add to playlist failed', respObj.error.errors);
}