mirror of https://github.com/buster-so/buster.git
add braintrust logger for server
This commit is contained in:
parent
301a671d6b
commit
31fb2e54ae
|
@ -5,6 +5,12 @@ import { z } from 'zod';
|
|||
import { loadRootEnv } from '@buster/env-utils';
|
||||
loadRootEnv();
|
||||
|
||||
// Initialize Braintrust logger
|
||||
import { initBraintrustLogger } from '@buster/ai';
|
||||
|
||||
// Initialize Braintrust logger
|
||||
initBraintrustLogger();
|
||||
|
||||
// Import custom middleware
|
||||
import { corsMiddleware } from './middleware/cors';
|
||||
import { loggerMiddleware } from './middleware/logger';
|
||||
|
|
|
@ -63,4 +63,4 @@
|
|||
"yaml": "^2.8.1",
|
||||
"zod": "catalog:"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,3 +3,6 @@ export * from './tool-call-repair';
|
|||
|
||||
// Message conversion utilities
|
||||
export * from './message-conversion';
|
||||
|
||||
// Logger utilities
|
||||
export * from './logger';
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
import { initLogger } from 'braintrust';
|
||||
|
||||
/**
|
||||
* Initialize Braintrust logger with environment configuration
|
||||
* @param options Optional configuration to override defaults
|
||||
* @returns Initialized Braintrust logger
|
||||
*/
|
||||
export function initBraintrustLogger(options?: {
|
||||
apiKey?: string;
|
||||
projectName?: string;
|
||||
}) {
|
||||
const apiKey = options?.apiKey || process.env.BRAINTRUST_KEY;
|
||||
const projectName = options?.projectName || process.env.ENVIRONMENT || 'development';
|
||||
|
||||
if (!apiKey) {
|
||||
throw new Error('BRAINTRUST_KEY is not set');
|
||||
}
|
||||
|
||||
return initLogger({
|
||||
apiKey,
|
||||
projectName,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-export initLogger from braintrust for direct access if needed
|
||||
*/
|
||||
export { initLogger } from 'braintrust';
|
Loading…
Reference in New Issue