Add in Pino logging and make UI consistent across the app.
This commit is contained in:
parent
727746030c
commit
300040bd58
19 changed files with 590 additions and 235 deletions
|
@ -10,8 +10,6 @@ export async function askGemini(content)
|
|||
|
||||
const GOOGLE_API_KEY = await getSetting('GEMINI_API_KEY');
|
||||
|
||||
console.log('Google API Key:', GOOGLE_API_KEY); // Debugging line to check the key
|
||||
|
||||
if (!GOOGLE_API_KEY)
|
||||
{
|
||||
throw new Error('Google API key is not set in the database.');
|
||||
|
|
47
src-server/utils/prisma-pino-transport.js
Normal file
47
src-server/utils/prisma-pino-transport.js
Normal file
|
@ -0,0 +1,47 @@
|
|||
import { PrismaClient } from '@prisma/client';
|
||||
import build from 'pino-abstract-transport';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
export default async function(opts)
|
||||
{
|
||||
return build(async(source) =>
|
||||
{
|
||||
for await (const obj of source)
|
||||
{
|
||||
try
|
||||
{
|
||||
const { time, level, msg, ...meta } = obj;
|
||||
// Pino levels are numeric, convert to string names if needed
|
||||
const levelMap = {
|
||||
'10': 'trace',
|
||||
'20': 'debug',
|
||||
'30': 'info',
|
||||
'40': 'warn',
|
||||
'50': 'error',
|
||||
'60': 'fatal'
|
||||
};
|
||||
const levelString = levelMap[level] || 'info'; // Default to info
|
||||
|
||||
await prisma.log.create({
|
||||
data: {
|
||||
timestamp: new Date(time),
|
||||
level: levelString,
|
||||
message: msg,
|
||||
// Store remaining properties in the meta field if it exists
|
||||
meta: Object.keys(meta).length > 0 ? meta : undefined,
|
||||
},
|
||||
});
|
||||
}
|
||||
catch (error)
|
||||
{
|
||||
console.error('Failed to write log to database:', error);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
async close(err)
|
||||
{
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue