mirror of
https://github.com/pockethost/pockethost.git
synced 2025-11-28 08:11:01 +00:00
feat(multi): settings now logged in DEBUG mode
This commit is contained in:
parent
737b4b855a
commit
517f602384
8
.changeset/olive-jars-grab.md
Normal file
8
.changeset/olive-jars-grab.md
Normal file
@ -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
|
||||||
@ -27,7 +27,7 @@
|
|||||||
"pocketbase": "^0.21.3"
|
"pocketbase": "^0.21.3"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"pockethost": "workspace:^1.3.0"
|
"pockethost": "workspace:^1.5.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^20.8.10",
|
"@types/node": "^20.8.10",
|
||||||
|
|||||||
@ -1,5 +1,12 @@
|
|||||||
import { join } from 'path'
|
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`
|
export const PLUGIN_NAME = `plugin-auto-admin`
|
||||||
|
|
||||||
@ -14,3 +21,7 @@ const settings = Settings({
|
|||||||
|
|
||||||
export const LOGIN = () => settings.PH_AUTO_ADMIN_LOGIN
|
export const LOGIN = () => settings.PH_AUTO_ADMIN_LOGIN
|
||||||
export const PASSWORD = () => settings.PH_AUTO_ADMIN_PASSWORD
|
export const PASSWORD = () => settings.PH_AUTO_ADMIN_PASSWORD
|
||||||
|
|
||||||
|
if (DEBUG()) {
|
||||||
|
logSettings(settings)
|
||||||
|
}
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"pockethost": "workspace:^1.3.0"
|
"pockethost": "workspace:^1.5.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^20.8.10",
|
"@types/node": "^20.8.10",
|
||||||
|
|||||||
@ -1,11 +1,16 @@
|
|||||||
import { join } from 'path'
|
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 PLUGIN_NAME = `plugin-cloudflare-request-logger`
|
||||||
|
|
||||||
export const HOME_DIR =
|
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({
|
const settings = Settings({
|
||||||
PH_CLOUDFLARE_REQUEST_LOGGER_HOME: mkPath(HOME_DIR, { create: true }),
|
PH_CLOUDFLARE_REQUEST_LOGGER_HOME: mkPath(HOME_DIR, { create: true }),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (DEBUG()) {
|
||||||
|
logSettings(settings)
|
||||||
|
}
|
||||||
|
|||||||
@ -27,7 +27,7 @@
|
|||||||
"typescript": "^5.4.5"
|
"typescript": "^5.4.5"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"pockethost": "workspace:^1.3.0"
|
"pockethost": "workspace:^1.5.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"json-stringify-safe": "^5.0.1"
|
"json-stringify-safe": "^5.0.1"
|
||||||
|
|||||||
16
packages/plugin-console-logger/src/constants.ts
Normal file
16
packages/plugin-console-logger/src/constants.ts
Normal file
@ -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)
|
||||||
|
}
|
||||||
@ -6,6 +6,8 @@ import {
|
|||||||
isLevelLte,
|
isLevelLte,
|
||||||
onLogAction,
|
onLogAction,
|
||||||
} from 'pockethost'
|
} from 'pockethost'
|
||||||
|
import { PLUGIN_NAME } from './constants'
|
||||||
|
import { dbg } from './log'
|
||||||
|
|
||||||
export const LogLevelConsoleMap = {
|
export const LogLevelConsoleMap = {
|
||||||
[LogLevelName.Trace]: console.trace,
|
[LogLevelName.Trace]: console.trace,
|
||||||
@ -49,6 +51,8 @@ const plugin: PocketHostPlugin = async ({}) => {
|
|||||||
}
|
}
|
||||||
LogLevelConsoleMap[levelIn](...finalArgs)
|
LogLevelConsoleMap[levelIn](...finalArgs)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
dbg(`initializing ${PLUGIN_NAME}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default plugin
|
export default plugin
|
||||||
|
|||||||
5
packages/plugin-console-logger/src/log.ts
Normal file
5
packages/plugin-console-logger/src/log.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { LoggerService } from 'pockethost'
|
||||||
|
import { PLUGIN_NAME } from './constants'
|
||||||
|
|
||||||
|
const logger = LoggerService().create(PLUGIN_NAME)
|
||||||
|
export const { dbg, info } = logger
|
||||||
@ -31,7 +31,7 @@
|
|||||||
"semver": "^7.6.2"
|
"semver": "^7.6.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"pockethost": "workspace:^1.3.0"
|
"pockethost": "workspace:^1.5.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^5.4.5"
|
"typescript": "^5.4.5"
|
||||||
|
|||||||
16
packages/plugin-launcher-spawn/src/constants.ts
Normal file
16
packages/plugin-launcher-spawn/src/constants.ts
Normal file
@ -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)
|
||||||
|
}
|
||||||
@ -1,10 +1,9 @@
|
|||||||
import { Mutex } from 'async-mutex'
|
import { Mutex } from 'async-mutex'
|
||||||
|
import { info } from 'console'
|
||||||
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs'
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs'
|
||||||
import getPort from 'get-port'
|
import getPort from 'get-port'
|
||||||
import { gobot } from 'gobot'
|
import { gobot } from 'gobot'
|
||||||
import { join } from 'path'
|
|
||||||
import {
|
import {
|
||||||
LoggerService,
|
|
||||||
PocketHostPlugin,
|
PocketHostPlugin,
|
||||||
doAfterInstanceStartedAction,
|
doAfterInstanceStartedAction,
|
||||||
doAfterInstanceStoppedAction,
|
doAfterInstanceStoppedAction,
|
||||||
@ -19,18 +18,13 @@ import {
|
|||||||
import {
|
import {
|
||||||
APEX_DOMAIN,
|
APEX_DOMAIN,
|
||||||
INSTANCE_DATA_DIR,
|
INSTANCE_DATA_DIR,
|
||||||
PH_HOME,
|
|
||||||
PORT,
|
PORT,
|
||||||
exitHook,
|
exitHook,
|
||||||
tryFetch,
|
tryFetch,
|
||||||
} from 'pockethost/core'
|
} from 'pockethost/core'
|
||||||
import { gte } from 'semver'
|
import { gte } from 'semver'
|
||||||
|
import { PLUGIN_NAME } from './constants'
|
||||||
const HOME =
|
import { dbg } from './log'
|
||||||
process.env.PH_BASIC_LAUNCHER_HOME || join(PH_HOME(), `plugin-basic-launcher`)
|
|
||||||
|
|
||||||
const logger = LoggerService().create('plugin-basic-launcher')
|
|
||||||
export const { dbg, info } = logger
|
|
||||||
|
|
||||||
export type InstanceFields = {
|
export type InstanceFields = {
|
||||||
subdomain: string
|
subdomain: string
|
||||||
@ -71,6 +65,8 @@ const writeMeta = async (instance: InstanceFields) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const plugin: PocketHostPlugin = async ({}) => {
|
const plugin: PocketHostPlugin = async ({}) => {
|
||||||
|
dbg(`initializing ${PLUGIN_NAME}`)
|
||||||
|
|
||||||
/** Display some informational alerts to help the user get started. */
|
/** Display some informational alerts to help the user get started. */
|
||||||
onAfterServerStartAction(async () => {
|
onAfterServerStartAction(async () => {
|
||||||
info(`Listening for requests on *.${APEX_DOMAIN()}`)
|
info(`Listening for requests on *.${APEX_DOMAIN()}`)
|
||||||
|
|||||||
5
packages/plugin-launcher-spawn/src/log.ts
Normal file
5
packages/plugin-launcher-spawn/src/log.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { LoggerService } from 'pockethost'
|
||||||
|
import { PLUGIN_NAME } from './constants'
|
||||||
|
|
||||||
|
const logger = LoggerService().create(PLUGIN_NAME)
|
||||||
|
export const { dbg, info } = logger
|
||||||
@ -21,8 +21,8 @@
|
|||||||
"url": "https://github.com/benallfree"
|
"url": "https://github.com/benallfree"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"peerDependencies": {
|
||||||
"pockethost": "workspace:^1.0.0"
|
"pockethost": "workspace:^1.5.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^20.8.10",
|
"@types/node": "^20.8.10",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user