mirror of
https://github.com/jeffvli/feishin.git
synced 2026-08-08 05:12:57 +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:
@@ -9,6 +9,8 @@ import {
|
||||
} from '.';
|
||||
import { orderSearchResults } from './shared';
|
||||
|
||||
import log from '/@/main/logger';
|
||||
|
||||
const SEARCH_URL = 'https://genius.com/api/search/song';
|
||||
|
||||
// Adapted from https://github.com/NyaomiDEV/Sunamu/blob/master/src/main/lyricproviders/genius.ts
|
||||
@@ -100,7 +102,7 @@ export async function getLyricsBySongId(url: string): Promise<null | string> {
|
||||
try {
|
||||
result = await axios.get<string>(url, { responseType: 'text' });
|
||||
} catch (e) {
|
||||
console.error('Genius lyrics request got an error!', (e as Error)?.message);
|
||||
log.error('Genius lyrics request got an error!', (e as Error)?.message);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -138,7 +140,7 @@ export async function getSearchResults(
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('Genius search request got an error!', (e as Error)?.message);
|
||||
log.error('Genius search request got an error!', (e as Error)?.message);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -193,7 +195,7 @@ async function getSongId(
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('Genius search request got an error!', (e as Error)?.message);
|
||||
log.error('Genius search request got an error!', (e as Error)?.message);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
getSearchResults as searchSimpMusic,
|
||||
} from './simpmusic';
|
||||
|
||||
import log from '/@/main/logger';
|
||||
import { Song } from '/@/shared/types/domain-types';
|
||||
|
||||
export enum LyricSource {
|
||||
@@ -110,7 +111,7 @@ const searchAllSources = async (
|
||||
allSearchResults.push(...result.value.searchResults);
|
||||
} else if (result.status === 'rejected') {
|
||||
const index = settled.indexOf(result);
|
||||
console.error(`Error searching ${sources[index]} for lyrics:`, result.reason);
|
||||
log.error(`Error searching ${sources[index]} for lyrics:`, result.reason);
|
||||
}
|
||||
}
|
||||
return allSearchResults;
|
||||
@@ -174,7 +175,7 @@ const getRemoteLyrics = async (song: Song) => {
|
||||
};
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error fetching lyrics from ${bestMatch.source}:`, error);
|
||||
log.error(`Error fetching lyrics from ${bestMatch.source}:`, error);
|
||||
}
|
||||
|
||||
if (lyricsFromSource) {
|
||||
|
||||
@@ -9,6 +9,8 @@ import {
|
||||
} from '.';
|
||||
import { orderSearchResults } from './shared';
|
||||
|
||||
import log from '/@/main/logger';
|
||||
|
||||
const FETCH_URL = 'https://lrclib.net/api/get';
|
||||
const SEEARCH_URL = 'https://lrclib.net/api/search';
|
||||
|
||||
@@ -46,7 +48,7 @@ export async function getLyricsBySongId(songId: string): Promise<null | string>
|
||||
try {
|
||||
result = await axios.get<LrcLibTrackResponse>(`${FETCH_URL}/${songId}`);
|
||||
} catch (e) {
|
||||
console.error('LrcLib lyrics request got an error!', (e as Error)?.message);
|
||||
log.error('LrcLib lyrics request got an error!', (e as Error)?.message);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -71,7 +73,7 @@ export async function getSearchResults(
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('LrcLib search request got an error!', (e as Error)?.message);
|
||||
log.error('LrcLib search request got an error!', (e as Error)?.message);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -109,7 +111,7 @@ export async function query(
|
||||
timeout: TIMEOUT_MS,
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('LrcLib search request got an error!', (e as Error).message);
|
||||
log.error('LrcLib search request got an error!', (e as Error).message);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ import {
|
||||
import { store } from '../settings';
|
||||
import { orderSearchResults } from './shared';
|
||||
|
||||
import log from '/@/main/logger';
|
||||
|
||||
const SEARCH_URL = 'https://music.163.com/api/search/get';
|
||||
const LYRICS_URL = 'https://music.163.com/api/song/lyric';
|
||||
|
||||
@@ -81,7 +83,7 @@ export async function getLyricsBySongId(songId: string): Promise<null | string>
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('NetEase lyrics request got an error!', e);
|
||||
log.error('NetEase lyrics request got an error!', e);
|
||||
return null;
|
||||
}
|
||||
const enableTranslation = store.get('enableNeteaseTranslation', false) as boolean;
|
||||
@@ -114,7 +116,7 @@ export async function getSearchResults(
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('NetEase search request got an error!', e);
|
||||
log.error('NetEase search request got an error!', e);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ import {
|
||||
} from '.';
|
||||
import { orderSearchResults } from './shared';
|
||||
|
||||
import log from '/@/main/logger';
|
||||
|
||||
const API_URL = 'https://api-lyrics.simpmusic.org/v1';
|
||||
|
||||
const TIMEOUT_MS = 5000;
|
||||
@@ -38,7 +40,7 @@ export async function getLyricsBySongId(songId: string): Promise<null | string>
|
||||
timeout: TIMEOUT_MS,
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('SimpMusic lyrics request errored:', (e as Error)?.message);
|
||||
log.error('SimpMusic lyrics request errored:', (e as Error)?.message);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -63,7 +65,7 @@ export async function getSearchResults(
|
||||
timeout: TIMEOUT_MS,
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('SimpMusic search errored:', (e as Error)?.message);
|
||||
log.error('SimpMusic search errored:', (e as Error)?.message);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -95,7 +97,7 @@ export async function query(
|
||||
timeout: TIMEOUT_MS,
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('SimpMusic search errored:', (e as Error).message);
|
||||
log.error('SimpMusic search errored:', (e as Error).message);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -109,7 +111,7 @@ export async function query(
|
||||
timeout: TIMEOUT_MS,
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('SimpMusic lyrics fetch errored:', (e as Error).message);
|
||||
log.error('SimpMusic lyrics fetch errored:', (e as Error).message);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user