mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-28 13:41:02 +00:00
feat(packages/shared): add logger factory
- @revanced/websocket-api now also utilizes the new logger from the shared package - @revanced/websocket-api/utils/checkEnv has been renamed to its full form - It also no longer returns anything as it's no longer needed
This commit is contained in:
@@ -3,7 +3,7 @@ import type { Wit } from 'node-wit'
|
||||
import type { Worker as TesseractWorker } from 'tesseract.js'
|
||||
import { ClientPacketObject } from '../classes/Client.js'
|
||||
import type { Config } from '../utils/getConfig.js'
|
||||
import type { Logger } from '../utils/logger.js'
|
||||
import type { Logger } from '@revanced/bot-shared'
|
||||
|
||||
export { default as parseTextEventHandler } from './parseText.js'
|
||||
export { default as parseImageEventHandler } from './parseImage.js'
|
||||
|
||||
@@ -14,13 +14,8 @@ const parseImageEventHandler: EventHandler<ClientOperation.ParseImage> = async (
|
||||
d: { image_url: imageUrl, id },
|
||||
} = packet
|
||||
|
||||
logger.debug(
|
||||
`Client ${client.id} requested to parse image from URL:`,
|
||||
imageUrl,
|
||||
)
|
||||
logger.debug(
|
||||
`Queue currently has ${queue.remaining}/${config.ocrConcurrentQueues} items in it`,
|
||||
)
|
||||
logger.debug(`Client ${client.id} requested to parse image from URL:`, imageUrl)
|
||||
logger.debug(`Queue currently has ${queue.remaining}/${config.ocrConcurrentQueues} items in it`)
|
||||
|
||||
if (queue.remaining < config.ocrConcurrentQueues) queue.shift()
|
||||
await queue.wait()
|
||||
@@ -30,10 +25,7 @@ const parseImageEventHandler: EventHandler<ClientOperation.ParseImage> = async (
|
||||
|
||||
const { data, jobId } = await tesseractWorker.recognize(imageUrl)
|
||||
|
||||
logger.debug(
|
||||
`Recognized image from URL for client ${client.id} (job ${jobId}):`,
|
||||
data.text,
|
||||
)
|
||||
logger.debug(`Recognized image from URL for client ${client.id} (job ${jobId}):`, data.text)
|
||||
await client.send({
|
||||
op: ServerOperation.ParsedImage,
|
||||
d: {
|
||||
@@ -42,10 +34,7 @@ const parseImageEventHandler: EventHandler<ClientOperation.ParseImage> = async (
|
||||
},
|
||||
})
|
||||
} catch {
|
||||
logger.error(
|
||||
`Failed to parse image from URL for client ${client.id}:`,
|
||||
imageUrl,
|
||||
)
|
||||
logger.error(`Failed to parse image from URL for client ${client.id}:`, imageUrl)
|
||||
await client.send({
|
||||
op: ServerOperation.ParseImageFailed,
|
||||
d: {
|
||||
|
||||
@@ -4,10 +4,7 @@ import { inspect as inspectObject } from 'node:util'
|
||||
|
||||
import type { EventHandler } from './index.js'
|
||||
|
||||
const parseTextEventHandler: EventHandler<ClientOperation.ParseText> = async (
|
||||
packet,
|
||||
{ witClient, logger },
|
||||
) => {
|
||||
const parseTextEventHandler: EventHandler<ClientOperation.ParseText> = async (packet, { witClient, logger }) => {
|
||||
const {
|
||||
client,
|
||||
d: { text, id },
|
||||
|
||||
Reference in New Issue
Block a user