diff --git a/.changeset/olive-jars-grab.md b/.changeset/olive-jars-grab.md new file mode 100644 index 00000000..8059527e --- /dev/null +++ b/.changeset/olive-jars-grab.md @@ -0,0 +1,8 @@ +--- +'@pockethost/plugin-cloudflare-request-logger': patch +'@pockethost/plugin-console-logger': patch +'@pockethost/plugin-launcher-spawn': patch +'@pockethost/plugin-auto-admin': patch +--- + +Settings are now logged in DEBUG mode diff --git a/packages/plugin-auto-admin/package.json b/packages/plugin-auto-admin/package.json index e165336c..7eec9dae 100644 --- a/packages/plugin-auto-admin/package.json +++ b/packages/plugin-auto-admin/package.json @@ -27,7 +27,7 @@ "pocketbase": "^0.21.3" }, "peerDependencies": { - "pockethost": "workspace:^1.3.0" + "pockethost": "workspace:^1.5.0" }, "devDependencies": { "@types/node": "^20.8.10", diff --git a/packages/plugin-auto-admin/src/constants.ts b/packages/plugin-auto-admin/src/constants.ts index 43335d41..ab5e586e 100644 --- a/packages/plugin-auto-admin/src/constants.ts +++ b/packages/plugin-auto-admin/src/constants.ts @@ -1,5 +1,12 @@ import { join } from 'path' -import { PH_HOME, Settings, mkPath, mkString } from 'pockethost/core' +import { DEBUG } from 'pockethost' +import { + PH_HOME, + Settings, + logSettings, + mkPath, + mkString, +} from 'pockethost/core' export const PLUGIN_NAME = `plugin-auto-admin` @@ -14,3 +21,7 @@ const settings = Settings({ export const LOGIN = () => settings.PH_AUTO_ADMIN_LOGIN export const PASSWORD = () => settings.PH_AUTO_ADMIN_PASSWORD + +if (DEBUG()) { + logSettings(settings) +} diff --git a/packages/plugin-cloudflare-request-logger/package.json b/packages/plugin-cloudflare-request-logger/package.json index 718f0d05..a996d136 100644 --- a/packages/plugin-cloudflare-request-logger/package.json +++ b/packages/plugin-cloudflare-request-logger/package.json @@ -22,7 +22,7 @@ }, "license": "MIT", "dependencies": { - "pockethost": "workspace:^1.3.0" + "pockethost": "workspace:^1.5.0" }, "devDependencies": { "@types/node": "^20.8.10", diff --git a/packages/plugin-cloudflare-request-logger/src/constants.ts b/packages/plugin-cloudflare-request-logger/src/constants.ts index 291e09f4..589a2858 100644 --- a/packages/plugin-cloudflare-request-logger/src/constants.ts +++ b/packages/plugin-cloudflare-request-logger/src/constants.ts @@ -1,11 +1,16 @@ import { join } from 'path' -import { PH_HOME, Settings, mkPath } from 'pockethost/core' +import { DEBUG } from 'pockethost' +import { PH_HOME, Settings, logSettings, mkPath } from 'pockethost/core' export const PLUGIN_NAME = `plugin-cloudflare-request-logger` export const HOME_DIR = - process.env.PH_CLOUDFLARE_REQUEST_LOGGER_HOME || join(PH_HOME(),PLUGIN_NAME) + process.env.PH_CLOUDFLARE_REQUEST_LOGGER_HOME || join(PH_HOME(), PLUGIN_NAME) const settings = Settings({ PH_CLOUDFLARE_REQUEST_LOGGER_HOME: mkPath(HOME_DIR, { create: true }), }) + +if (DEBUG()) { + logSettings(settings) +} diff --git a/packages/plugin-console-logger/package.json b/packages/plugin-console-logger/package.json index 8a53ee52..260abb7d 100644 --- a/packages/plugin-console-logger/package.json +++ b/packages/plugin-console-logger/package.json @@ -27,7 +27,7 @@ "typescript": "^5.4.5" }, "peerDependencies": { - "pockethost": "workspace:^1.3.0" + "pockethost": "workspace:^1.5.0" }, "dependencies": { "json-stringify-safe": "^5.0.1" diff --git a/packages/plugin-console-logger/src/constants.ts b/packages/plugin-console-logger/src/constants.ts new file mode 100644 index 00000000..ac4121bf --- /dev/null +++ b/packages/plugin-console-logger/src/constants.ts @@ -0,0 +1,16 @@ +import { join } from 'path' +import { DEBUG } from 'pockethost' +import { PH_HOME, Settings, logSettings, mkPath } from 'pockethost/core' + +export const PLUGIN_NAME = `plugin-console-logger` + +export const HOME_DIR = + process.env.PH_CONSOLE_LOGGER_HOME || join(PH_HOME(), PLUGIN_NAME) + +const settings = Settings({ + PH_CONSOLE_LOGGER__HOME: mkPath(HOME_DIR, { create: true }), +}) + +if (DEBUG()) { + logSettings(settings) +} diff --git a/packages/plugin-console-logger/src/index.ts b/packages/plugin-console-logger/src/index.ts index fd451216..70d87fae 100644 --- a/packages/plugin-console-logger/src/index.ts +++ b/packages/plugin-console-logger/src/index.ts @@ -6,6 +6,8 @@ import { isLevelLte, onLogAction, } from 'pockethost' +import { PLUGIN_NAME } from './constants' +import { dbg } from './log' export const LogLevelConsoleMap = { [LogLevelName.Trace]: console.trace, @@ -49,6 +51,8 @@ const plugin: PocketHostPlugin = async ({}) => { } LogLevelConsoleMap[levelIn](...finalArgs) }) + + dbg(`initializing ${PLUGIN_NAME}`) } export default plugin diff --git a/packages/plugin-console-logger/src/log.ts b/packages/plugin-console-logger/src/log.ts new file mode 100644 index 00000000..54fb6ab9 --- /dev/null +++ b/packages/plugin-console-logger/src/log.ts @@ -0,0 +1,5 @@ +import { LoggerService } from 'pockethost' +import { PLUGIN_NAME } from './constants' + +const logger = LoggerService().create(PLUGIN_NAME) +export const { dbg, info } = logger diff --git a/packages/plugin-launcher-spawn/package.json b/packages/plugin-launcher-spawn/package.json index 85deec67..08a4229d 100644 --- a/packages/plugin-launcher-spawn/package.json +++ b/packages/plugin-launcher-spawn/package.json @@ -31,7 +31,7 @@ "semver": "^7.6.2" }, "peerDependencies": { - "pockethost": "workspace:^1.3.0" + "pockethost": "workspace:^1.5.0" }, "devDependencies": { "typescript": "^5.4.5" diff --git a/packages/plugin-launcher-spawn/src/constants.ts b/packages/plugin-launcher-spawn/src/constants.ts new file mode 100644 index 00000000..b364528e --- /dev/null +++ b/packages/plugin-launcher-spawn/src/constants.ts @@ -0,0 +1,16 @@ +import { join } from 'path' +import { DEBUG } from 'pockethost' +import { PH_HOME, Settings, logSettings, mkPath } from 'pockethost/core' + +export const PLUGIN_NAME = `plugin-launcher-spawn` + +export const HOME_DIR = + process.env.PH_LAUNCHER_SPAWN_HOME || join(PH_HOME(), PLUGIN_NAME) + +const settings = Settings({ + PH_LAUNCHER_SPAWN_HOME: mkPath(HOME_DIR, { create: true }), +}) + +if (DEBUG()) { + logSettings(settings) +} diff --git a/packages/plugin-launcher-spawn/src/index.ts b/packages/plugin-launcher-spawn/src/index.ts index 3c43cb0a..91547a6f 100644 --- a/packages/plugin-launcher-spawn/src/index.ts +++ b/packages/plugin-launcher-spawn/src/index.ts @@ -1,10 +1,9 @@ import { Mutex } from 'async-mutex' +import { info } from 'console' import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs' import getPort from 'get-port' import { gobot } from 'gobot' -import { join } from 'path' import { - LoggerService, PocketHostPlugin, doAfterInstanceStartedAction, doAfterInstanceStoppedAction, @@ -19,18 +18,13 @@ import { import { APEX_DOMAIN, INSTANCE_DATA_DIR, - PH_HOME, PORT, exitHook, tryFetch, } from 'pockethost/core' import { gte } from 'semver' - -const HOME = - process.env.PH_BASIC_LAUNCHER_HOME || join(PH_HOME(), `plugin-basic-launcher`) - -const logger = LoggerService().create('plugin-basic-launcher') -export const { dbg, info } = logger +import { PLUGIN_NAME } from './constants' +import { dbg } from './log' export type InstanceFields = { subdomain: string @@ -71,6 +65,8 @@ const writeMeta = async (instance: InstanceFields) => { } const plugin: PocketHostPlugin = async ({}) => { + dbg(`initializing ${PLUGIN_NAME}`) + /** Display some informational alerts to help the user get started. */ onAfterServerStartAction(async () => { info(`Listening for requests on *.${APEX_DOMAIN()}`) diff --git a/packages/plugin-launcher-spawn/src/log.ts b/packages/plugin-launcher-spawn/src/log.ts new file mode 100644 index 00000000..54fb6ab9 --- /dev/null +++ b/packages/plugin-launcher-spawn/src/log.ts @@ -0,0 +1,5 @@ +import { LoggerService } from 'pockethost' +import { PLUGIN_NAME } from './constants' + +const logger = LoggerService().create(PLUGIN_NAME) +export const { dbg, info } = logger diff --git a/plop-templates/plugin/package.json b/plop-templates/plugin/package.json index 8f402835..f2b68965 100644 --- a/plop-templates/plugin/package.json +++ b/plop-templates/plugin/package.json @@ -21,8 +21,8 @@ "url": "https://github.com/benallfree" }, "license": "MIT", - "dependencies": { - "pockethost": "workspace:^1.0.0" + "peerDependencies": { + "pockethost": "workspace:^1.5.0" }, "devDependencies": { "@types/node": "^20.8.10",