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"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"pockethost": "workspace:^1.3.0"
|
||||
"pockethost": "workspace:^1.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.8.10",
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"pockethost": "workspace:^1.3.0"
|
||||
"pockethost": "workspace:^1.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.8.10",
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
@ -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"
|
||||
|
||||
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,
|
||||
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
|
||||
|
||||
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"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"pockethost": "workspace:^1.3.0"
|
||||
"pockethost": "workspace:^1.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"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 { 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()}`)
|
||||
|
||||
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"
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"pockethost": "workspace:^1.0.0"
|
||||
"peerDependencies": {
|
||||
"pockethost": "workspace:^1.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.8.10",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user