mirror of
https://github.com/neosubhamoy/neodlp.git
synced 2026-03-22 12:35:49 +05:30
refactor: improved and persisted logging
This commit is contained in:
@@ -115,9 +115,9 @@ export function IncompleteDownload({ state }: IncompleteDownloadProps) {
|
||||
) : (
|
||||
<span>{state.download_status.charAt(0).toUpperCase() + state.download_status.slice(1)}</span>
|
||||
)} {
|
||||
(debugMode && state.download_id) || (state.download_status === 'errored' && state.download_id) && (
|
||||
(debugMode && state.download_id) || (state.download_status === 'errored' && state.download_id) ? (
|
||||
<><span className="text-primary">•</span> ID: {state.download_id.toUpperCase()}</>
|
||||
)} {
|
||||
) : null} {
|
||||
state.download_status === 'downloading' && state.status !== 'finished' && state.speed && (
|
||||
<><span className="text-primary">•</span> Speed: {formatSpeed(state.speed)}</>
|
||||
)} {state.download_status === 'downloading' && state.eta && (
|
||||
|
||||
@@ -658,6 +658,10 @@ export default function useDownloader() {
|
||||
}
|
||||
});
|
||||
|
||||
command.stderr.on('data', line => {
|
||||
if (line.trim() !== '') LOG.info(`YT-DLP Download ${downloadId}`, line);
|
||||
});
|
||||
|
||||
try {
|
||||
videoInfoSaver.mutate({
|
||||
video_id: videoId,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useLogsStore } from "@/services/store";
|
||||
import { warn, debug, info, error } from "@tauri-apps/plugin-log";
|
||||
|
||||
export function useLogger() {
|
||||
const logs = useLogsStore((state) => state.logs);
|
||||
@@ -8,18 +9,23 @@ export function useLogger() {
|
||||
const logger = {
|
||||
info: (context: string, message: string) => {
|
||||
addLog({ timestamp: Date.now(), level: 'info', context, message });
|
||||
info(`${context}: ${message}`);
|
||||
},
|
||||
warning: (context: string, message: string) => {
|
||||
addLog({ timestamp: Date.now(), level: 'warning', context, message });
|
||||
warn(`${context}: ${message}`);
|
||||
},
|
||||
error: (context: string, message: string) => {
|
||||
addLog({ timestamp: Date.now(), level: 'error', context, message });
|
||||
error(`${context}: ${message}`);
|
||||
},
|
||||
debug: (context: string, message: string) => {
|
||||
addLog({ timestamp: Date.now(), level: 'debug', context, message });
|
||||
debug(`${context}: ${message}`);
|
||||
},
|
||||
progress: (context: string, message: string) => {
|
||||
addLog({ timestamp: Date.now(), level: 'progress', context, message });
|
||||
info(`${context}: ${message}`);
|
||||
},
|
||||
getLogs: () => logs,
|
||||
clearLogs,
|
||||
|
||||
Reference in New Issue
Block a user