feat: add debug logging to torrent client
Some checks are pending
Check / check (push) Waiting to run

This commit is contained in:
ThaUnknown 2025-06-19 21:54:27 +02:00
parent 0a2fbfec45
commit 0cd0db7e53
No known key found for this signature in database
4 changed files with 10 additions and 5 deletions

View file

@ -1,6 +1,6 @@
{
"name": "ui",
"version": "6.3.68",
"version": "6.3.69",
"license": "BUSL-1.1",
"private": true,
"packageManager": "pnpm@9.14.4",

View file

@ -93,6 +93,7 @@ export default Object.assign<Native, Partial<Native>>({
torrentStats: async (): Promise<TorrentInfo> => ({ peers: rnd(), seeders: rnd(), leechers: rnd(), progress: Math.random(), down: rnd(100000000), up: rnd(100000000), name: 'Amebku.webm', downloaded: rnd(100000), hash: '1234567890abcdef', size: 1234567890, eta: rnd() }),
torrents: async (): Promise<TorrentInfo[]> => [{ peers: rnd(), seeders: rnd(), leechers: rnd(), progress: Math.random(), down: rnd(100000000), up: rnd(100000000), name: 'Amebku.webm', downloaded: rnd(100000), hash: '1234567890abcdef', size: 1234567890, eta: rnd() }],
defaultTransparency: () => false,
errors: async () => undefined
errors: async () => undefined,
debug: async () => undefined
// @ts-expect-error idk
}, globalThis.native as Partial<Native>)

View file

@ -6,6 +6,12 @@ import { defaults } from '.'
export const settings = persisted('settings', defaults, { beforeRead: value => ({ ...defaults, ...value }) })
export const debug = persisted('debug', '')
debug.subscribe((value) => {
native.debug(value)
})
settings.subscribe(settings => {
const { torrentPersist, torrentDHT, torrentStreamedDownload, torrentSpeed, maxConns, torrentPort, dhtPort, torrentPeX } = settings
native.updateSettings({ torrentPersist, torrentDHT, torrentStreamedDownload, torrentSpeed, maxConns, torrentPort, dhtPort, torrentPeX })

View file

@ -1,5 +1,4 @@
<script lang='ts'>
import { persisted } from 'svelte-persisted-store'
import { toast } from 'svelte-sonner'
import SettingCard from '$lib/components/SettingCard.svelte'
@ -8,7 +7,7 @@
import { Switch } from '$lib/components/ui/switch'
import { client } from '$lib/modules/anilist'
import native from '$lib/modules/native'
import { settings, SUPPORTS } from '$lib/modules/settings'
import { settings, SUPPORTS, debug } from '$lib/modules/settings'
const debugOpts = {
'': 'None',
@ -16,7 +15,6 @@
'torrent:*,webtorrent:*,simple-peer,bittorrent-protocol,bittorrent-dht,bittorrent-lsd,torrent-discovery,bittorrent-tracker:*,ut_metadata,nat-pmp,nat-api': 'Torrent',
'ui:*': 'Interface'
}
const debug = persisted('debug', '')
async function copyLogs () {
const logs = await native.getLogs()