add extra logging

This commit is contained in:
nin0 2025-05-03 08:46:46 -04:00
parent 73dbf48c44
commit 7b0485f2cd
Signed by: nin0
SSH key fingerprint: SHA256:NOoDnFVvZNFvqfXCIhzr6oCTDImZAbTTuyAysZ8Ufk8
2 changed files with 7 additions and 2 deletions

View file

@ -1,9 +1,12 @@
import { fastify } from ".";
import { state } from "./utils/state"; import { state } from "./utils/state";
export async function getGrokAuthedCookies() { export async function getGrokAuthedCookies() {
if (!process.env.FLARESOLVERR_BASE_URL) if (!process.env.FLARESOLVERR_BASE_URL)
throw new Error("No flaresolverr found"); throw new Error("No flaresolverr found");
fastify.log.info("Refreshing Grok meta");
const req = await fetch( const req = await fetch(
`${process.env.FLARESOLVERR_BASE_URL!.replace(/\/(v1)?$/, "")}/v1`, `${process.env.FLARESOLVERR_BASE_URL!.replace(/\/(v1)?$/, "")}/v1`,
{ {
@ -22,7 +25,7 @@ export async function getGrokAuthedCookies() {
if (!req.ok) throw new Error(await req.text()); if (!req.ok) throw new Error(await req.text());
const data = await req.json(); const data = await req.json();
if (data.status !== "ok") { if (data.status !== "ok") {
console.error(data); fastify.log.error(data);
throw new Error(data); throw new Error(data);
} }
@ -41,4 +44,6 @@ export async function getGrokAuthedCookies() {
requests: 3 requests: 3
} }
}; };
fastify.log.info("Refreshed Grok meta");
} }

View file

@ -2,7 +2,7 @@ import Fastify from "fastify";
import { Yapper } from "./utils/Yapper"; import { Yapper } from "./utils/Yapper";
import { getGrokAuthedCookies } from "./grokCookies"; import { getGrokAuthedCookies } from "./grokCookies";
const fastify = Fastify({ export const fastify = Fastify({
loggerInstance: new Yapper(), loggerInstance: new Yapper(),
disableRequestLogging: true disableRequestLogging: true
}); });