mirror of
https://github.com/jeffvli/feishin.git
synced 2026-08-08 13:23:16 +02:00
improve app logging
- consolidate electron-log and expand support-oriented logging - consolidate log levels to info / trace only - add system/server diagnostics exporter
This commit is contained in:
@@ -5,8 +5,7 @@ import { useCallback, useEffect, useImperativeHandle, useRef, useState } from 'r
|
||||
|
||||
import { AudioPlayer, PlayerOnProgressProps } from '/@/renderer/features/player/audio-player/types';
|
||||
import { convertToLogVolume } from '/@/renderer/features/player/audio-player/utils/player-utils';
|
||||
import { LogCategory, logFn } from '/@/renderer/utils/logger';
|
||||
import { logMsg } from '/@/renderer/utils/logger-message';
|
||||
import { logger } from '/@/renderer/utils/logger';
|
||||
import { PlayerStatus } from '/@/shared/types/types';
|
||||
|
||||
export interface WebPlayerEngineHandle extends AudioPlayer {
|
||||
@@ -174,6 +173,21 @@ export const WebPlayerEngine = (props: WebPlayerEngineProps) => {
|
||||
player2Ref.current?.getInternalPlayer()?.pause();
|
||||
}, []);
|
||||
|
||||
const mediaErrorLabel = (code: number | undefined) => {
|
||||
switch (code) {
|
||||
case MediaError.MEDIA_ERR_ABORTED:
|
||||
return 'ABORTED';
|
||||
case MediaError.MEDIA_ERR_DECODE:
|
||||
return 'DECODE';
|
||||
case MediaError.MEDIA_ERR_NETWORK:
|
||||
return 'NETWORK';
|
||||
case MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED:
|
||||
return 'SRC_NOT_SUPPORTED';
|
||||
default:
|
||||
return 'unknown';
|
||||
}
|
||||
};
|
||||
|
||||
const handleOnError = (
|
||||
playerRef: React.RefObject<null | ReactPlayer>,
|
||||
onEnded: () => void,
|
||||
@@ -188,27 +202,30 @@ export const WebPlayerEngine = (props: WebPlayerEngineProps) => {
|
||||
}
|
||||
|
||||
const { error } = target;
|
||||
|
||||
logFn.error(logMsg[LogCategory.PLAYER].playbackError, {
|
||||
category: LogCategory.PLAYER,
|
||||
meta: { error },
|
||||
});
|
||||
const code = error?.code;
|
||||
const label = mediaErrorLabel(code);
|
||||
|
||||
const isNetworkError =
|
||||
error?.code === MediaError.MEDIA_ERR_NETWORK ||
|
||||
error?.code === MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED;
|
||||
code === MediaError.MEDIA_ERR_NETWORK ||
|
||||
code === MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED;
|
||||
|
||||
if (isNetworkError) {
|
||||
if (networkRetryCountRef.current < MAX_NETWORK_RETRIES) {
|
||||
networkRetryCountRef.current += 1;
|
||||
logger.warn('Playback error, retrying', {
|
||||
code,
|
||||
label,
|
||||
retryCount: networkRetryCountRef.current,
|
||||
});
|
||||
const audio = target;
|
||||
setTimeout(() => {
|
||||
pauseBothPlayers();
|
||||
audio.load();
|
||||
audio.play().catch(() => {
|
||||
logFn.error(logMsg[LogCategory.PLAYER].playbackError, {
|
||||
category: LogCategory.PLAYER,
|
||||
meta: { error: 'Failed to play audio after network error' },
|
||||
logger.error('Playback error, retries exhausted', {
|
||||
code,
|
||||
label,
|
||||
retryCount: networkRetryCountRef.current,
|
||||
});
|
||||
});
|
||||
}, NETWORK_RETRY_DELAY_MS);
|
||||
@@ -216,14 +233,24 @@ export const WebPlayerEngine = (props: WebPlayerEngineProps) => {
|
||||
}
|
||||
}
|
||||
|
||||
if (error?.code !== MediaError.MEDIA_ERR_DECODE && !isNetworkError) {
|
||||
if (code !== MediaError.MEDIA_ERR_DECODE && !isNetworkError) {
|
||||
return;
|
||||
}
|
||||
|
||||
pauseBothPlayers();
|
||||
if (error?.code === MediaError.MEDIA_ERR_DECODE) {
|
||||
if (code === MediaError.MEDIA_ERR_DECODE) {
|
||||
logger.error('Playback decode error, skipping track', {
|
||||
code,
|
||||
label,
|
||||
retryCount: networkRetryCountRef.current,
|
||||
});
|
||||
onEnded();
|
||||
} else {
|
||||
logger.error('Playback error, pausing', {
|
||||
code,
|
||||
label,
|
||||
retryCount: networkRetryCountRef.current,
|
||||
});
|
||||
if (onErrorPause) {
|
||||
onErrorPause();
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ import {
|
||||
usePlaybackType,
|
||||
useSettingsStoreActions,
|
||||
} from '/@/renderer/store';
|
||||
import { logFn } from '/@/renderer/utils/logger';
|
||||
import { logger } from '/@/renderer/utils/logger';
|
||||
import { toast } from '/@/shared/components/toast/toast';
|
||||
import { LibraryItem } from '/@/shared/types/domain-types';
|
||||
import { PlayerType } from '/@/shared/types/types';
|
||||
@@ -99,7 +99,7 @@ function detectBrowserProfile() {
|
||||
}
|
||||
}
|
||||
|
||||
logFn.info('DIRECT_PLAY_PROFILES', { meta: DIRECT_PLAY_PROFILES });
|
||||
logger.debug('DIRECT_PLAY_PROFILES', DIRECT_PLAY_PROFILES);
|
||||
|
||||
return DIRECT_PLAY_PROFILES;
|
||||
}
|
||||
@@ -158,6 +158,8 @@ export const AudioPlayers = () => {
|
||||
);
|
||||
};
|
||||
|
||||
const mpvPlayerListener = isElectron() ? window.api.mpvPlayerListener : null;
|
||||
|
||||
const AudioPlayersContent = ({
|
||||
audioContext,
|
||||
audioDeviceId,
|
||||
@@ -179,6 +181,24 @@ const AudioPlayersContent = ({
|
||||
}) => {
|
||||
const isRadioActive = useIsRadioActive();
|
||||
|
||||
useEffect(() => {
|
||||
logger.info('Playback engine', { playbackType });
|
||||
}, [playbackType]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!mpvPlayerListener) {
|
||||
return;
|
||||
}
|
||||
|
||||
mpvPlayerListener.rendererPlayerFallback((isFallback: boolean) => {
|
||||
if (isFallback) {
|
||||
logger.warn('Playback engine fell back to web');
|
||||
} else {
|
||||
logger.info('Playback engine using local (mpv)');
|
||||
}
|
||||
});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (webAudio && 'AudioContext' in window) {
|
||||
let context: AudioContext;
|
||||
|
||||
@@ -18,8 +18,7 @@ import {
|
||||
import { playlistsQueries } from '/@/renderer/features/playlists/api/playlists-api';
|
||||
import { songsQueries } from '/@/renderer/features/songs/api/songs-api';
|
||||
import { AddToQueueType, usePlayerActions, useSettingsStore } from '/@/renderer/store';
|
||||
import { LogCategory, logFn } from '/@/renderer/utils/logger';
|
||||
import { logMsg } from '/@/renderer/utils/logger-message';
|
||||
import { logger } from '/@/renderer/utils/logger';
|
||||
import { shuffle as shuffleArray } from '/@/renderer/utils/shuffle';
|
||||
import { sortSongsByFetchedOrder } from '/@/shared/api/utils';
|
||||
import { Checkbox } from '/@/shared/components/checkbox/checkbox';
|
||||
@@ -229,22 +228,20 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
if (typeof type === 'object' && 'edge' in type && type.edge !== null) {
|
||||
const edge = type.edge === 'top' ? 'top' : 'bottom';
|
||||
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].addToQueueByData, {
|
||||
category: LogCategory.PLAYER,
|
||||
meta: {
|
||||
data: data.length,
|
||||
edge,
|
||||
filtered: filteredData.length,
|
||||
type,
|
||||
uniqueId: type.uniqueId,
|
||||
},
|
||||
logger.debug('Added to queue by data', {
|
||||
data: data.length,
|
||||
edge,
|
||||
filtered: filteredData.length,
|
||||
type,
|
||||
uniqueId: type.uniqueId,
|
||||
});
|
||||
|
||||
storeActions.addToQueueByUniqueId(filteredData, type.uniqueId, edge, playSongId);
|
||||
} else {
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].addToQueueByType, {
|
||||
category: LogCategory.PLAYER,
|
||||
meta: { data: data.length, filtered: filteredData.length, type },
|
||||
logger.debug('Added to queue by type', {
|
||||
data: data.length,
|
||||
filtered: filteredData.length,
|
||||
type,
|
||||
});
|
||||
|
||||
storeActions.addToQueueByType(filteredData, type as Play, playSongId);
|
||||
@@ -281,10 +278,7 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
};
|
||||
|
||||
try {
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].addToQueueByFetch, {
|
||||
category: LogCategory.PLAYER,
|
||||
meta: { ids: id, itemType, serverId, type },
|
||||
});
|
||||
logger.debug('Added to queue by fetch', { ids: id, itemType, serverId, type });
|
||||
|
||||
const songs = await queryClient.fetchQuery({
|
||||
gcTime: 0,
|
||||
@@ -361,10 +355,7 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
let toastId: null | string = null;
|
||||
let fetchId: null | string = null;
|
||||
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].addToQueueByListQuery, {
|
||||
category: LogCategory.PLAYER,
|
||||
meta: { itemType, query, serverId, type },
|
||||
});
|
||||
logger.debug('Added to queue by list query', { itemType, query, serverId, type });
|
||||
|
||||
try {
|
||||
let totalCount = 0;
|
||||
@@ -440,10 +431,7 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
autoClose: false,
|
||||
message: t('player.playbackFetchCancel'),
|
||||
onClose: () => {
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].cancelledFetch, {
|
||||
category: LogCategory.PLAYER,
|
||||
meta: { itemType, serverId },
|
||||
});
|
||||
logger.debug('Cancelled fetch', { itemType, serverId });
|
||||
|
||||
queryClient.cancelQueries({
|
||||
exact: false,
|
||||
@@ -538,19 +526,14 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
);
|
||||
|
||||
const clearQueue = useCallback(() => {
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].clearQueue, {
|
||||
category: LogCategory.PLAYER,
|
||||
});
|
||||
logger.debug('Cleared queue');
|
||||
|
||||
storeActions.clearQueue();
|
||||
}, [storeActions]);
|
||||
|
||||
const clearSelected = useCallback(
|
||||
(items: QueueSong[]) => {
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].clearSelected, {
|
||||
category: LogCategory.PLAYER,
|
||||
meta: { items: items.length },
|
||||
});
|
||||
logger.debug('Cleared selected', { items: items.length });
|
||||
|
||||
storeActions.clearSelected(items);
|
||||
},
|
||||
@@ -559,10 +542,7 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
|
||||
const decreaseVolume = useCallback(
|
||||
(amount: number) => {
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].decreaseVolume, {
|
||||
category: LogCategory.PLAYER,
|
||||
meta: { amount },
|
||||
});
|
||||
logger.debug('Decreased volume', { amount });
|
||||
|
||||
storeActions.decreaseVolume(amount);
|
||||
},
|
||||
@@ -570,9 +550,7 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
);
|
||||
|
||||
const getQueue = useCallback(() => {
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].clearQueue, {
|
||||
category: LogCategory.PLAYER,
|
||||
});
|
||||
logger.debug('Cleared queue');
|
||||
|
||||
const queue = storeActions.getQueue();
|
||||
return queue.items;
|
||||
@@ -580,10 +558,7 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
|
||||
const increaseVolume = useCallback(
|
||||
(amount: number) => {
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].increaseVolume, {
|
||||
category: LogCategory.PLAYER,
|
||||
meta: { amount },
|
||||
});
|
||||
logger.debug('Increased volume', { amount });
|
||||
|
||||
storeActions.increaseVolume(amount);
|
||||
},
|
||||
@@ -592,9 +567,7 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
|
||||
const mediaNext = useCallback(
|
||||
(toNextAlbum: boolean) => {
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].mediaNext, {
|
||||
category: LogCategory.PLAYER,
|
||||
});
|
||||
logger.debug('Media next');
|
||||
|
||||
storeActions.mediaNext(toNextAlbum);
|
||||
},
|
||||
@@ -602,19 +575,14 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
);
|
||||
|
||||
const mediaPause = useCallback(() => {
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].mediaPause, {
|
||||
category: LogCategory.PLAYER,
|
||||
});
|
||||
logger.debug('Media pause');
|
||||
|
||||
storeActions.mediaPause();
|
||||
}, [storeActions]);
|
||||
|
||||
const mediaPlay = useCallback(
|
||||
(id?: string) => {
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].mediaPlay, {
|
||||
category: LogCategory.PLAYER,
|
||||
meta: { id },
|
||||
});
|
||||
logger.debug('Media play', { id });
|
||||
|
||||
storeActions.mediaPlay(id);
|
||||
},
|
||||
@@ -623,10 +591,7 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
|
||||
const mediaPlayByIndex = useCallback(
|
||||
(index: number) => {
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].mediaPlayByIndex, {
|
||||
category: LogCategory.PLAYER,
|
||||
meta: { index },
|
||||
});
|
||||
logger.debug('Media play by index', { index });
|
||||
|
||||
storeActions.mediaPlayByIndex(index);
|
||||
},
|
||||
@@ -635,9 +600,7 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
|
||||
const mediaPrevious = useCallback(
|
||||
(toPreviousAlbum: boolean) => {
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].mediaPrevious, {
|
||||
category: LogCategory.PLAYER,
|
||||
});
|
||||
logger.debug('Media previous');
|
||||
|
||||
storeActions.mediaPrevious(toPreviousAlbum);
|
||||
},
|
||||
@@ -646,10 +609,7 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
|
||||
const mediaStop = useCallback(
|
||||
(options?: { reset?: boolean }) => {
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].mediaStop, {
|
||||
category: LogCategory.PLAYER,
|
||||
meta: { reset: options?.reset },
|
||||
});
|
||||
logger.debug('Media stop', { reset: options?.reset });
|
||||
|
||||
storeActions.mediaStop(options);
|
||||
},
|
||||
@@ -658,10 +618,7 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
|
||||
const mediaSeekToTimestamp = useCallback(
|
||||
(timestamp: number) => {
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].mediaSeekToTimestamp, {
|
||||
category: LogCategory.PLAYER,
|
||||
meta: { timestamp },
|
||||
});
|
||||
logger.debug('Media seek to timestamp', { timestamp });
|
||||
|
||||
storeActions.mediaSeekToTimestamp(timestamp);
|
||||
},
|
||||
@@ -669,30 +626,23 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
);
|
||||
|
||||
const mediaSkipBackward = useCallback(() => {
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].mediaSkipBackward, {
|
||||
category: LogCategory.PLAYER,
|
||||
});
|
||||
logger.debug('Media skip backward');
|
||||
|
||||
storeActions.mediaSkipBackward();
|
||||
}, [storeActions]);
|
||||
|
||||
const mediaSkipForward = useCallback(() => {
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].mediaSkipForward, {
|
||||
category: LogCategory.PLAYER,
|
||||
});
|
||||
logger.debug('Media skip forward');
|
||||
|
||||
storeActions.mediaSkipForward();
|
||||
}, [storeActions]);
|
||||
|
||||
const setQueue = useCallback(
|
||||
(data: Song[], index?: number, position?: number) => {
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].setQueue, {
|
||||
category: LogCategory.PLAYER,
|
||||
meta: {
|
||||
data: data.length,
|
||||
index,
|
||||
position,
|
||||
},
|
||||
logger.debug('Set queue', {
|
||||
data: data.length,
|
||||
index,
|
||||
position,
|
||||
});
|
||||
|
||||
storeActions.setQueue(data, index, position);
|
||||
@@ -702,10 +652,7 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
|
||||
const setSpeed = useCallback(
|
||||
(speed: number) => {
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].setSpeed, {
|
||||
category: LogCategory.PLAYER,
|
||||
meta: { speed },
|
||||
});
|
||||
logger.debug('Set speed', { speed });
|
||||
|
||||
storeActions.setSpeed(speed);
|
||||
},
|
||||
@@ -713,27 +660,20 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
);
|
||||
|
||||
const mediaToggleMute = useCallback(() => {
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].mediaToggleMute, {
|
||||
category: LogCategory.PLAYER,
|
||||
});
|
||||
logger.debug('Media toggle mute');
|
||||
|
||||
storeActions.mediaToggleMute();
|
||||
}, [storeActions]);
|
||||
|
||||
const mediaTogglePlayPause = useCallback(() => {
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].mediaTogglePlayPause, {
|
||||
category: LogCategory.PLAYER,
|
||||
});
|
||||
logger.debug('Media toggle play pause');
|
||||
|
||||
storeActions.mediaTogglePlayPause();
|
||||
}, [storeActions]);
|
||||
|
||||
const moveSelectedTo = useCallback(
|
||||
(items: QueueSong[], edge: 'bottom' | 'top', uniqueId: string) => {
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].moveSelectedTo, {
|
||||
category: LogCategory.PLAYER,
|
||||
meta: { edge, items, uniqueId },
|
||||
});
|
||||
logger.debug('Moved selected to', { edge, items, uniqueId });
|
||||
|
||||
storeActions.moveSelectedTo(items, uniqueId, edge);
|
||||
},
|
||||
@@ -742,10 +682,7 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
|
||||
const moveSelectedToBottom = useCallback(
|
||||
(items: QueueSong[]) => {
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].moveSelectedToBottom, {
|
||||
category: LogCategory.PLAYER,
|
||||
meta: { items },
|
||||
});
|
||||
logger.debug('Moved selected to bottom', { items });
|
||||
|
||||
storeActions.moveSelectedToBottom(items);
|
||||
},
|
||||
@@ -754,10 +691,7 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
|
||||
const moveSelectedToNext = useCallback(
|
||||
(items: QueueSong[]) => {
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].moveSelectedToNext, {
|
||||
category: LogCategory.PLAYER,
|
||||
meta: { items },
|
||||
});
|
||||
logger.debug('Moved selected to next', { items });
|
||||
|
||||
storeActions.moveSelectedToNext(items);
|
||||
},
|
||||
@@ -766,10 +700,7 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
|
||||
const moveSelectedToTop = useCallback(
|
||||
(items: QueueSong[]) => {
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].moveSelectedToTop, {
|
||||
category: LogCategory.PLAYER,
|
||||
meta: { items },
|
||||
});
|
||||
logger.debug('Moved selected to top', { items });
|
||||
|
||||
storeActions.moveSelectedToTop(items);
|
||||
},
|
||||
@@ -778,10 +709,7 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
|
||||
const setVolume = useCallback(
|
||||
(volume: number) => {
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].setVolume, {
|
||||
category: LogCategory.PLAYER,
|
||||
meta: { volume },
|
||||
});
|
||||
logger.debug('Set volume', { volume });
|
||||
|
||||
storeActions.setVolume(volume);
|
||||
},
|
||||
@@ -790,10 +718,7 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
|
||||
const setRepeat = useCallback(
|
||||
(repeat: PlayerRepeat) => {
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].setRepeat, {
|
||||
category: LogCategory.PLAYER,
|
||||
meta: { repeat },
|
||||
});
|
||||
logger.debug('Set repeat', { repeat });
|
||||
|
||||
storeActions.setRepeat(repeat);
|
||||
},
|
||||
@@ -802,10 +727,7 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
|
||||
const setShuffle = useCallback(
|
||||
(shuffle: PlayerShuffle) => {
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].setShuffle, {
|
||||
category: LogCategory.PLAYER,
|
||||
meta: { shuffle },
|
||||
});
|
||||
logger.debug('Set shuffle', { shuffle });
|
||||
|
||||
storeActions.setShuffle(shuffle);
|
||||
},
|
||||
@@ -813,27 +735,20 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
);
|
||||
|
||||
const shuffle = useCallback(() => {
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].shuffle, {
|
||||
category: LogCategory.PLAYER,
|
||||
});
|
||||
logger.debug('Shuffle');
|
||||
|
||||
storeActions.shuffle();
|
||||
}, [storeActions]);
|
||||
|
||||
const shuffleAll = useCallback(() => {
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].shuffleAll, {
|
||||
category: LogCategory.PLAYER,
|
||||
});
|
||||
logger.debug('Shuffle all');
|
||||
|
||||
storeActions.shuffleAll();
|
||||
}, [storeActions]);
|
||||
|
||||
const shuffleSelected = useCallback(
|
||||
(items: QueueSong[]) => {
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].shuffleSelected, {
|
||||
category: LogCategory.PLAYER,
|
||||
meta: { items },
|
||||
});
|
||||
logger.debug('Shuffle selected', { items });
|
||||
|
||||
storeActions.shuffleSelected(items);
|
||||
},
|
||||
@@ -841,17 +756,13 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
);
|
||||
|
||||
const toggleRepeat = useCallback(() => {
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].toggleRepeat, {
|
||||
category: LogCategory.PLAYER,
|
||||
});
|
||||
logger.debug('Toggle repeat');
|
||||
|
||||
storeActions.toggleRepeat();
|
||||
}, [storeActions]);
|
||||
|
||||
const toggleShuffle = useCallback(() => {
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].toggleShuffle, {
|
||||
category: LogCategory.PLAYER,
|
||||
});
|
||||
logger.debug('Toggle shuffle');
|
||||
|
||||
storeActions.toggleShuffle();
|
||||
}, [storeActions]);
|
||||
|
||||
@@ -16,8 +16,7 @@ import {
|
||||
usePlayerStoreBase,
|
||||
useSettingsStore,
|
||||
} from '/@/renderer/store';
|
||||
import { LogCategory, logFn } from '/@/renderer/utils/logger';
|
||||
import { logMsg } from '/@/renderer/utils/logger-message';
|
||||
import { logger } from '/@/renderer/utils/logger';
|
||||
import { hasFeature } from '/@/shared/api/utils';
|
||||
import { LibraryItem } from '/@/shared/types/domain-types';
|
||||
import { ServerFeature } from '/@/shared/types/features-types';
|
||||
@@ -65,9 +64,9 @@ export const useAutoDJ = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].autoPlayTriggered, {
|
||||
category: LogCategory.PLAYER,
|
||||
meta: { remaining: properties.remaining, songId: properties.song?.id },
|
||||
logger.info('Auto play triggered', {
|
||||
remaining: properties.remaining,
|
||||
songId: properties.song?.id,
|
||||
});
|
||||
|
||||
try {
|
||||
@@ -143,9 +142,9 @@ export const useAutoDJ = () => {
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
logFn.error(logMsg[LogCategory.PLAYER].autoPlayFailed, {
|
||||
category: LogCategory.PLAYER,
|
||||
meta: { error: (error as Error).message, songId: properties.song?.id },
|
||||
logger.error('Auto play failed', {
|
||||
error: (error as Error).message,
|
||||
songId: properties.song?.id,
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
@@ -14,8 +14,7 @@ import {
|
||||
useSettingsStore,
|
||||
useTimestampStoreBase,
|
||||
} from '/@/renderer/store';
|
||||
import { LogCategory, logFn } from '/@/renderer/utils/logger';
|
||||
import { logMsg } from '/@/renderer/utils/logger-message';
|
||||
import { logger } from '/@/renderer/utils/logger';
|
||||
import { hasFeature } from '/@/shared/api/utils';
|
||||
import { LibraryItem, QueueSong, ServerType } from '/@/shared/types/domain-types';
|
||||
import { ServerFeature } from '/@/shared/types/features-types';
|
||||
@@ -211,12 +210,9 @@ export const useScrobble = () => {
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
logFn.debug(logMsg[LogCategory.SCROBBLE].scrobbledTimeupdate, {
|
||||
category: LogCategory.SCROBBLE,
|
||||
meta: {
|
||||
id: song.id,
|
||||
reason: 'after submission',
|
||||
},
|
||||
logger.debug('Scrobbled a timeupdate event', {
|
||||
id: song.id,
|
||||
reason: 'after submission',
|
||||
});
|
||||
},
|
||||
},
|
||||
@@ -305,8 +301,7 @@ export const useScrobble = () => {
|
||||
// },
|
||||
// {
|
||||
// onSuccess: () => {
|
||||
// logFn.debug(logMsg[LogCategory.SCROBBLE].scrobbledTimeupdate, {
|
||||
// category: LogCategory.SCROBBLE,
|
||||
// logFn.debug("Scrobbled a timeupdate event", {
|
||||
// meta: {
|
||||
// id: currentSong.id,
|
||||
// },
|
||||
@@ -342,12 +337,9 @@ export const useScrobble = () => {
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
logFn.debug(logMsg[LogCategory.SCROBBLE].scrobbledSubmission, {
|
||||
category: LogCategory.SCROBBLE,
|
||||
meta: {
|
||||
id: currentSong.id,
|
||||
reason: 'from listened time',
|
||||
},
|
||||
logger.info('Scrobbled a submission event', {
|
||||
id: currentSong.id,
|
||||
reason: 'from listened time',
|
||||
});
|
||||
sendProgressAfterSubmission(currentSong);
|
||||
},
|
||||
@@ -399,11 +391,8 @@ export const useScrobble = () => {
|
||||
silent: true,
|
||||
});
|
||||
} catch (error) {
|
||||
logFn.error('an error occurred while sending a desktop notification', {
|
||||
category: LogCategory.SCROBBLE,
|
||||
meta: {
|
||||
error: error as Error,
|
||||
},
|
||||
logger.error('an error occurred while sending a desktop notification', {
|
||||
error: error as Error,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -447,11 +436,8 @@ export const useScrobble = () => {
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
logFn.debug(logMsg[LogCategory.SCROBBLE].scrobbledStart, {
|
||||
category: LogCategory.SCROBBLE,
|
||||
meta: {
|
||||
id: currentSong.id,
|
||||
},
|
||||
logger.info('Scrobbled a start event', {
|
||||
id: currentSong.id,
|
||||
});
|
||||
},
|
||||
},
|
||||
@@ -480,11 +466,8 @@ export const useScrobble = () => {
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
logFn.debug(logMsg[LogCategory.SCROBBLE].scrobbledStop, {
|
||||
category: LogCategory.SCROBBLE,
|
||||
meta: {
|
||||
id: previousSong.id,
|
||||
},
|
||||
logger.info('Scrobbled a stop event', {
|
||||
id: previousSong.id,
|
||||
});
|
||||
},
|
||||
},
|
||||
@@ -578,11 +561,8 @@ export const useScrobble = () => {
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
logFn.debug(logMsg[LogCategory.SCROBBLE].scrobbledTimeupdate, {
|
||||
category: LogCategory.SCROBBLE,
|
||||
meta: {
|
||||
id: currentSong.id,
|
||||
},
|
||||
logger.debug('Scrobbled a timeupdate event', {
|
||||
id: currentSong.id,
|
||||
});
|
||||
},
|
||||
},
|
||||
@@ -633,11 +613,8 @@ export const useScrobble = () => {
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
logFn.debug(logMsg[LogCategory.SCROBBLE].scrobbledPause, {
|
||||
category: LogCategory.SCROBBLE,
|
||||
meta: {
|
||||
id: currentSong.id,
|
||||
},
|
||||
logger.debug('Scrobbled a pause event', {
|
||||
id: currentSong.id,
|
||||
});
|
||||
},
|
||||
},
|
||||
@@ -661,11 +638,8 @@ export const useScrobble = () => {
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
logFn.debug(logMsg[LogCategory.SCROBBLE].scrobbledUnpause, {
|
||||
category: LogCategory.SCROBBLE,
|
||||
meta: {
|
||||
id: currentSong.id,
|
||||
},
|
||||
logger.debug('Scrobbled an unpause event', {
|
||||
id: currentSong.id,
|
||||
});
|
||||
},
|
||||
},
|
||||
@@ -694,11 +668,8 @@ export const useScrobble = () => {
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
logFn.debug(logMsg[LogCategory.SCROBBLE].scrobbledStart, {
|
||||
category: LogCategory.SCROBBLE,
|
||||
meta: {
|
||||
id: currentSong.id,
|
||||
},
|
||||
logger.info('Scrobbled a start event', {
|
||||
id: currentSong.id,
|
||||
});
|
||||
},
|
||||
},
|
||||
@@ -726,11 +697,8 @@ export const useScrobble = () => {
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
logFn.debug(logMsg[LogCategory.SCROBBLE].scrobbledStop, {
|
||||
category: LogCategory.SCROBBLE,
|
||||
meta: {
|
||||
id: currentSong.id,
|
||||
},
|
||||
logger.info('Scrobbled a stop event', {
|
||||
id: currentSong.id,
|
||||
});
|
||||
},
|
||||
},
|
||||
@@ -777,12 +745,9 @@ export const useScrobble = () => {
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
logFn.debug(logMsg[LogCategory.SCROBBLE].scrobbledStart, {
|
||||
category: LogCategory.SCROBBLE,
|
||||
meta: {
|
||||
id: currentSong.id,
|
||||
reason: 'from repeat',
|
||||
},
|
||||
logger.info('Scrobbled a start event', {
|
||||
id: currentSong.id,
|
||||
reason: 'from repeat',
|
||||
});
|
||||
},
|
||||
},
|
||||
@@ -840,12 +805,9 @@ export const useScrobble = () => {
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
logFn.debug(logMsg[LogCategory.SCROBBLE].scrobbledSubmission, {
|
||||
category: LogCategory.SCROBBLE,
|
||||
meta: {
|
||||
id: song.id,
|
||||
reason: 'forced from UI',
|
||||
},
|
||||
logger.info('Scrobbled a submission event', {
|
||||
id: song.id,
|
||||
reason: 'forced from UI',
|
||||
});
|
||||
sendProgressAfterSubmission(song);
|
||||
},
|
||||
|
||||
@@ -6,7 +6,7 @@ import { api } from '/@/renderer/api';
|
||||
import { queryKeys } from '/@/renderer/api/query-keys';
|
||||
import { usePlayerEvents } from '/@/renderer/features/player/audio-player/hooks/use-player-events';
|
||||
import { updateQueueSong } from '/@/renderer/store/player.store';
|
||||
import { LogCategory, logFn } from '/@/renderer/utils/logger';
|
||||
import { logger } from '/@/renderer/utils/logger';
|
||||
import { QueueSong, SongDetailQuery } from '/@/shared/types/domain-types';
|
||||
|
||||
export const useUpdateCurrentSong = () => {
|
||||
@@ -43,22 +43,16 @@ export const useUpdateCurrentSong = () => {
|
||||
if (!isEqual(currentSongData, updatedSong)) {
|
||||
updateQueueSong(currentSong.id, updatedSong);
|
||||
|
||||
logFn.debug('Song updated in queue', {
|
||||
category: LogCategory.PLAYER,
|
||||
meta: {
|
||||
id: currentSong.id,
|
||||
name: updatedSong.name,
|
||||
},
|
||||
logger.debug('Song updated in queue', {
|
||||
id: currentSong.id,
|
||||
name: updatedSong.name,
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
logFn.error('Failed to update song in queue', {
|
||||
category: LogCategory.PLAYER,
|
||||
meta: {
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
id: currentSong.id,
|
||||
},
|
||||
logger.error('Failed to update song in queue', {
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
id: currentSong.id,
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
@@ -4,8 +4,7 @@ import { api } from '/@/renderer/api';
|
||||
import { queryKeys } from '/@/renderer/api/query-keys';
|
||||
import { folderQueries } from '/@/renderer/features/folders/api/folder-api';
|
||||
import { PlayerFilter, useSettingsStore } from '/@/renderer/store';
|
||||
import { LogCategory, logFn } from '/@/renderer/utils/logger';
|
||||
import { logMsg } from '/@/renderer/utils/logger-message';
|
||||
import { logger } from '/@/renderer/utils/logger';
|
||||
import { resolveSongPath } from '/@/renderer/utils/resolve-song-path';
|
||||
import { sortSongList } from '/@/shared/api/utils';
|
||||
import {
|
||||
@@ -435,23 +434,20 @@ export const filterSongsByPlayerFilters = (songs: Song[], filters: PlayerFilter[
|
||||
});
|
||||
|
||||
if (filteredSongs.length > 0) {
|
||||
logFn.debug(logMsg[LogCategory.PLAYER].playerFiltersApplied, {
|
||||
category: LogCategory.PLAYER,
|
||||
meta: {
|
||||
filteredCount: filteredSongs.length,
|
||||
filteredSongs: filteredSongs.map(({ filter, song }) => ({
|
||||
artist: song.artistName,
|
||||
condition: {
|
||||
field: filter.field,
|
||||
operator: filter.operator,
|
||||
value: filter.value,
|
||||
},
|
||||
songId: song.id,
|
||||
songName: song.name,
|
||||
})),
|
||||
originalCount: songs.length,
|
||||
remainingCount: filtered.length,
|
||||
},
|
||||
logger.debug('Player filters applied', {
|
||||
filteredCount: filteredSongs.length,
|
||||
filteredSongs: filteredSongs.map(({ filter, song }) => ({
|
||||
artist: song.artistName,
|
||||
condition: {
|
||||
field: filter.field,
|
||||
operator: filter.operator,
|
||||
value: filter.value,
|
||||
},
|
||||
songId: song.id,
|
||||
songName: song.name,
|
||||
})),
|
||||
originalCount: songs.length,
|
||||
remainingCount: filtered.length,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user