Skip to content

Commit

Permalink
Fix error logging (#1228)
Browse files Browse the repository at this point in the history
Logging was switched to Pino. For error logging, Pino wants the object first, and
then the string message. For example see this thread: pinojs/pino#673
  • Loading branch information
wdhorton authored May 31, 2024
1 parent 203e1c0 commit 6ca138c
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/lib/migrations/routines/03-add-tools-in-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const addToolsToSettings: Migration = {

settings
.createIndex({ tools: 1 })
.catch((e) => logger.error("Error creating index during tools migration", e));
.catch((e) => logger.error(e, "Error creating index during tools migration"));

return true;
},
Expand Down
2 changes: 1 addition & 1 deletion src/lib/server/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class Database {
});

this.client.connect().catch((err) => {
logger.error("Connection error", err);
logger.error(err, "Connection error");
process.exit(1);
});
this.client.db(env.MONGODB_DB_NAME + (import.meta.env.MODE === "test" ? "-test" : ""));
Expand Down
2 changes: 1 addition & 1 deletion src/lib/server/embeddingEndpoints/hfApi/embeddingHfApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export async function embeddingEndpointHfApi(

if (!response.ok) {
logger.error(await response.text());
logger.error("Failed to get embeddings from Hugging Face API", response);
logger.error(response, "Failed to get embeddings from Hugging Face API");
return [];
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/server/endpoints/cloudflare/endpointCloudflare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export async function endpointCloudflare(
try {
data = JSON.parse(jsonString);
} catch (e) {
logger.error("Failed to parse JSON", e);
logger.error(e, "Failed to parse JSON");
logger.error("Problematic JSON string:", jsonString);
continue; // Skip this iteration and try the next chunk
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/server/endpoints/langserve/endpointLangserve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export function endpointLangserve(
try {
data = JSON.parse(jsonString);
} catch (e) {
logger.error("Failed to parse JSON", e);
logger.error(e, "Failed to parse JSON");
logger.error("Problematic JSON string:", jsonString);
continue; // Skip this iteration and try the next chunk
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/server/endpoints/llamacpp/endpointLlamacpp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export function endpointLlamacpp(
try {
data = JSON.parse(jsonString);
} catch (e) {
logger.error("Failed to parse JSON", e);
logger.error(e, "Failed to parse JSON");
logger.error("Problematic JSON string:", jsonString);
continue; // Skip this iteration and try the next chunk
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/server/websearch/search/endpoints/searxng.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default async function searchSearxng(query: string): Promise<WebSearchSou
})
.then((response) => response.json() as Promise<{ results: { url: string }[] }>)
.catch((error) => {
logger.error("Failed to fetch or parse JSON", error);
logger.error(error, "Failed to fetch or parse JSON");
throw new Error("Failed to fetch or parse JSON", { cause: error });
});

Expand Down

0 comments on commit 6ca138c

Please sign in to comment.