feat: add more logging, include build version, shorten commit hash

This commit is contained in:
PalmDevs 2025-05-01 01:29:55 +07:00
parent f87c1fb584
commit ce07a1d6bf
No known key found for this signature in database
GPG key ID: 6FAE8F8677ACA8BA
5 changed files with 15 additions and 7 deletions

View file

@ -49,7 +49,7 @@ function runCatching(fn: () => void) {
// TODO(init): Move to use native module
alert(
// biome-ignore lint/style/useTemplate: I want this to be readable, thank you
`Failed to load Revenge (${__BUILD_COMMIT__}-${__BUILD_ENV__})\n` +
`Failed to load Revenge (v: ${__BUILD_VERSION__} c: ${__BUILD_COMMIT__} e: ${__BUILD_ENV__})\n` +
`Discord: ${ClientInfoModule.Version} (${ClientInfoModule.Build})\n` +
`Device: ${DeviceModule.deviceManufacturer} ${DeviceModule.deviceModel}\n\n` +
getErrorStack(e),

View file

@ -1,2 +1,2 @@
import './timing-log'
import './logging'
import './staff-settings'

View file

@ -10,17 +10,21 @@ let tsInit: number
registerPlugin(
{
id: 'revenge.timing-log',
name: 'Startup Timing Log',
description: "Log Revenge's startup timing into Discord's Startup Timing",
id: 'revenge.logging',
name: 'Logging',
description: "Extra logging for Revenge's internal modules",
icon: 'PaperIcon',
},
{
init() {
tsInit = performance.now()
AppStartPerformance.mark('👊', 'Plugins init', tsInit - tsReg)
},
start() {
start({ logger }) {
AppStartPerformance.mark('👊', 'Plugins start', performance.now() - tsInit)
logger.log(
`👊 Revenge. Discord, your way. (v: ${__BUILD_VERSION__} c: ${__BUILD_COMMIT__} e: ${__BUILD_ENV__})`,
)
},
},
PluginFlags.Enabled,

View file

@ -3,6 +3,8 @@ import { $, main } from 'bun'
import chalk from 'chalk'
import { type OutputChunk, type RolldownPlugin, rolldown } from 'rolldown'
import pkg from '../package.json'
// If this file is being run directly, build the project
if (main === import.meta.filename) build()
@ -24,7 +26,8 @@ export default async function build(dev = false, log = true) {
'.webp': 'dataurl',
},
define: {
__BUILD_COMMIT__: JSON.stringify(await $`git rev-parse HEAD`.text()),
__BUILD_VERSION__: JSON.stringify(pkg.version),
__BUILD_COMMIT__: JSON.stringify((await $`git rev-parse HEAD`.text()).substring(0, 7)),
__BUILD_ENV__: JSON.stringify(dev ? 'development' : 'production'),
__BUILD_FLAG_INIT_DISABLE_PATCH_LOG_PROMISE_REJECTIONS__: String(!dev),
},

1
types.d.ts vendored
View file

@ -3,6 +3,7 @@
declare global {
const __BUILD_ENV__: 'development' | 'production'
const __BUILD_COMMIT__: string
const __BUILD_VERSION__: string
const __BUILD_FLAG_INIT_DISABLE_PATCH_LOG_PROMISE_REJECTIONS__: boolean
}