plugin.api.log
Massimo Melina committed
May 1, 2022 at 20:14 UTC
9df26186404594946f20fe1353c1573dc2f1c6ce
2 files changed
+6
dev-plugins.md
+3
@@ -61,6 +61,7 @@ Let's first look at the things you can return:
61
Currently, these properties are supported:
62
- `type: 'string' | 'number' | 'boolean' | 'select' | 'multiselect'` . Default is `string`.
63
- `label: string` what name to display next to the field. Default is based on `key`.
64
+- `defaultValue: any` value to be used when nothing is set.
65
- `helperText: string` extra text printed next to the field.
66
67
Based on `type`, other properties are supported:
@@ -81,6 +82,8 @@ The `api` object you get as parameter of the `init` contains the following:
82
83
- `getConfig(key: string): any` get config's value set up by using `exports.config`.
84
85
+- `log(...args)` print log in a standard form for plugins.
86
+
87
- `const: object` all constants of the `const.ts` file are exposed here. E.g. BUILD_TIMESTAMP, API_VERSION, etc.
88
89
- `getConnections: Connections[]` retrieve current list of active connections.
server/src/plugins.ts
+3
@@ -198,6 +198,9 @@ async function rescan() {
198
require,
199
getConnections,
200
events,
201
+ log(...args: any[]) {
202
+ console.log('plugin', id, ':', ...args)
203
+ },
204
getConfig: (cfgKey: string) =>
205
pluginsConfig.get()?.[id]?.[cfgKey] ?? data.config?.[cfgKey]?.defaultValue
206
})