Skip to content

Commit dc08f43

Browse files
committed
feat(frontend): Print logs with plugin version if available
1 parent 4dcba38 commit dc08f43

3 files changed

Lines changed: 27 additions & 9 deletions

File tree

frontend/src/components/settings/pages/plugin_list/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
requestPluginInstall,
2424
} from '../../../../store';
2525
import { useSetting } from '../../../../utils/hooks/useSetting';
26+
import { getPluginDisplayName } from '../../../../utils/pluginHelpers';
2627
import { useDeckyState } from '../../../DeckyState';
2728
import PluginListLabel from './PluginListLabel';
2829

@@ -69,7 +70,7 @@ function PluginInteractables(props: { entry: ReorderableEntry<PluginTableData> }
6970
try {
7071
await reloadPluginBackend(name);
7172
} catch (err) {
72-
console.error('Error Reloading Plugin Backend', err);
73+
console.error(`Error Reloading Plugin Backend for ${getPluginDisplayName(name, version)}`, err);
7374
}
7475
}}
7576
>

frontend/src/plugin-loader.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import { checkForPluginUpdates } from './store';
3838
import TabsHook from './tabs-hook';
3939
import Toaster from './toaster';
4040
import { getVersionInfo } from './updater';
41+
import { getPluginDisplayName } from './utils/pluginHelpers';
4142
import { getSetting, setSetting } from './utils/settings';
4243
import TranslationHelper, { TranslationClass } from './utils/TranslationHelper';
4344

@@ -343,7 +344,7 @@ class PluginLoader extends Logger {
343344

344345
public dismountAll() {
345346
for (const plugin of this.plugins) {
346-
this.log(`Dismounting ${plugin.name}`);
347+
this.log(`Dismounting ${getPluginDisplayName(plugin.name, plugin.version)}`);
347348
plugin.onDismount?.();
348349
}
349350
}
@@ -403,14 +404,14 @@ class PluginLoader extends Logger {
403404
timeoutMS?: number,
404405
) {
405406
if (useQueue && this.reloadLock) {
406-
this.log('Reload currently in progress, adding to queue', name);
407+
this.log(`Reload currently in progress, adding ${getPluginDisplayName(name, version)} to queue`);
407408
this.pluginReloadQueue.push({ name, version: version, loadType });
408409
return;
409410
}
410411

411412
try {
412413
if (useQueue) this.reloadLock = true;
413-
this.log(`Trying to load ${name}`);
414+
this.log(`Trying to load ${getPluginDisplayName(name, version)}`);
414415

415416
this.unloadPlugin(name, true);
416417
const startTime = performance.now();
@@ -420,7 +421,7 @@ class PluginLoader extends Logger {
420421

421422
this.deckyState.setDisabledPlugins(this.deckyState.publicState().disabledPlugins.filter((d) => d.name !== name));
422423
this.deckyState.setPlugins(this.plugins);
423-
this.log(`Loaded ${name} in ${endTime - startTime}ms`);
424+
this.log(`Loaded ${getPluginDisplayName(name, version)} in ${endTime - startTime}ms`);
424425
} catch (e) {
425426
throw e;
426427
} finally {
@@ -502,16 +503,17 @@ class PluginLoader extends Logger {
502503
version: version,
503504
loadType,
504505
});
505-
} else throw new Error(`${name} frontend_bundle not OK`);
506+
} else throw new Error(`${getPluginDisplayName(name, version)} frontend_bundle not OK`);
506507
break;
507508

508509
default:
509-
throw new Error(`${name} has no defined loadType.`);
510+
throw new Error(`${getPluginDisplayName(name, version)} has no defined loadType.`);
510511
}
511512
} catch (e) {
512513
if (e === timeoutException) throw timeoutException;
513514

514-
this.error('Error loading plugin ' + name, e);
515+
this.error(`Error loading plugin ${getPluginDisplayName(name, version)}`, e);
516+
515517
const TheError: FC<{}> = () => (
516518
<PanelSection>
517519
<PanelSectionRow>
@@ -731,7 +733,8 @@ class PluginLoader extends Logger {
731733
backendAPI.useQuickAccessVisible = useQuickAccessVisible;
732734
}
733735

734-
this.debug(`${pluginName} connected to loader API.`);
736+
// Note: version info not available at connection time
737+
this.debug(`Plugin ${pluginName} connected to loader API.`);
735738
return backendAPI;
736739
},
737740
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* Returns a formatted display name for a plugin with version if available
3+
* @param name - The plugin name
4+
* @param version - The optional plugin version
5+
*
6+
* @returns Formatted string like "PluginName (v1.2.3)" or just "PluginName" if version is undefined
7+
*/
8+
export function getPluginDisplayName(name: string, version?: string): string {
9+
if (version) {
10+
return `${name} (v${version})`;
11+
}
12+
13+
return name;
14+
}

0 commit comments

Comments
 (0)