mirror of
https://github.com/labring/FastGPT.git
synced 2026-05-05 01:02:59 +08:00
V4.14.9 dev (#6555)
* feat: encapsulate logger (#6535) * feat: encapsulate logger * update engines --------- Co-authored-by: archer <545436317@qq.com> * next config * dev shell * Agent sandbox (#6532) * docs: switch to docs layout and apply black theme (#6533) * feat: add Gemini 3.1 models - Add gemini-3.1-pro-preview (released February 19, 2026) - Add gemini-3.1-flash-lite-preview (released March 3, 2026) Both models support: - 1M context window - 64k max response - Vision - Tool choice * docs: switch to docs layout and apply black theme - Change layout from notebook to docs - Update logo to icon + text format - Apply fumadocs black theme - Simplify global.css (keep only navbar and TOC styles) - Fix icon components to properly accept className props - Add mobile text overflow handling - Update Node engine requirement to >=20.x * doc * doc * lock * fix: ts * doc * doc --------- Co-authored-by: archer <archer@archerdeMac-mini.local> Co-authored-by: archer <545436317@qq.com> * Doc (#6493) * cloud doc * doc refactor * doc move * seo * remove doc * yml * doc * fix: tsconfig * fix: tsconfig * sandbox version (#6497) * sandbox version * add sandbox log * update lock * fix * fix: sandbox * doc * add console * i18n * sandbxo in agent * feat: agent sandbox * lock * feat: sandbox ui * sandbox check exists * env tempalte * doc * lock * sandbox in chat window * sandbox entry * fix: test * rename var * sandbox config tip * update sandbox lifecircle * update prompt * rename provider test * sandbox logger * yml --------- Co-authored-by: Archer <archer@fastgpt.io> Co-authored-by: archer <archer@archerdeMac-mini.local> * perf: sandbox error tip * Add sandbox limit and fix some issue (#6550) * sandbox in plan * fix: some issue * fix: test * editor default path * fix: comment * perf: sandbox worksapce * doc * perf: del sandbox * sandbox build * fix: test * fix: pr comment --------- Co-authored-by: Ryo <whoeverimf5@gmail.com> Co-authored-by: Archer <archer@fastgpt.io> Co-authored-by: archer <archer@archerdeMac-mini.local>
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
import { exit } from 'process';
|
||||
|
||||
/*
|
||||
Init system
|
||||
*/
|
||||
export async function register() {
|
||||
try {
|
||||
if (process.env.NEXT_RUNTIME === 'nodejs') {
|
||||
const { configureLogger, getLogger, LogCategories } = await import('@/service/logger');
|
||||
await configureLogger();
|
||||
const logger = getLogger(LogCategories.SYSTEM);
|
||||
|
||||
await import('@fastgpt/service/common/proxy');
|
||||
|
||||
// 基础系统初始化
|
||||
const [{ getToolList }, { connectMongo, connectionMongo, MONGO_URL }] = await Promise.all([
|
||||
import('@/service/tool/data'),
|
||||
import('@/service/mongo')
|
||||
@@ -17,10 +17,11 @@ export async function register() {
|
||||
await connectMongo(connectionMongo, MONGO_URL);
|
||||
await getToolList();
|
||||
|
||||
console.log('Init system success');
|
||||
logger.info('Init system success');
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('Init system error', error);
|
||||
const { getLogger, LogCategories } = await import('@/service/logger');
|
||||
getLogger(LogCategories.SYSTEM).error('Init system error', { error });
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { MongoDownloadCount } from '../mongo/models/download';
|
||||
import type { pluginTypeEnum } from '../mongo/models/download';
|
||||
import type z from 'zod';
|
||||
import { getLogger, LogCategories } from '../logger';
|
||||
|
||||
const logger = getLogger(LogCategories.MODULE.DOWNLOAD);
|
||||
|
||||
const BATCH_INTERVAL = 10000; // 10 seconds
|
||||
|
||||
@@ -64,9 +67,9 @@ const startBatchTimer = () => {
|
||||
|
||||
try {
|
||||
await MongoDownloadCount.bulkWrite(bulkOps);
|
||||
console.log(`Batch update download counts: ${bulkOps.length} items`);
|
||||
logger.info(`Batch update download counts: ${bulkOps.length} items`);
|
||||
} catch (error) {
|
||||
console.error('Batch update download counts failed:', error);
|
||||
logger.error('Batch update download counts failed', { error });
|
||||
}
|
||||
|
||||
// Clear cache
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import { configureLoggerFromEnv, getLogger } from '@fastgpt-sdk/logger';
|
||||
|
||||
export const LogCategories = {
|
||||
SYSTEM: ['system'] as const,
|
||||
INFRA: {
|
||||
MONGO: ['infra', 'mongo'] as const
|
||||
},
|
||||
MODULE: {
|
||||
API: ['marketplace', 'api'] as const,
|
||||
DOWNLOAD: ['marketplace', 'download'] as const
|
||||
}
|
||||
};
|
||||
|
||||
export async function configureLogger() {
|
||||
await configureLoggerFromEnv({
|
||||
env: process.env,
|
||||
defaultCategory: LogCategories.SYSTEM,
|
||||
defaultServiceName: 'fastgpt-marketplace',
|
||||
sensitiveProperties: ['fastgpt']
|
||||
});
|
||||
}
|
||||
|
||||
export { getLogger };
|
||||
@@ -1,5 +1,8 @@
|
||||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
import type { ApiRequestProps } from '@fastgpt/service/type/next';
|
||||
import { getLogger, LogCategories } from '../logger';
|
||||
|
||||
const logger = getLogger(LogCategories.MODULE.API);
|
||||
|
||||
export type NextApiHandler<T = any> = (
|
||||
req: ApiRequestProps,
|
||||
@@ -39,7 +42,7 @@ export const NextAPI = (...handlers: NextApiHandler[]): NextApiHandler => {
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Marketplace API Error:', error);
|
||||
logger.error('Marketplace API Error', { error });
|
||||
|
||||
if (!res.writableFinished) {
|
||||
res.status(500).json({
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Model, Schema } from 'mongoose';
|
||||
import { Mongoose } from 'mongoose';
|
||||
import { getLogger, LogCategories } from '@fastgpt/service/common/logger';
|
||||
import { getLogger, LogCategories } from '../logger';
|
||||
|
||||
export const MONGO_URL = process.env.MONGODB_URI ?? '';
|
||||
const maxConnecting = Math.max(30, Number(process.env.DB_MAX_LINK || 20));
|
||||
@@ -55,13 +55,13 @@ export async function connectMongo(db: Mongoose, url: string): Promise<Mongoose>
|
||||
db.set('strictQuery', 'throw');
|
||||
|
||||
db.connection.on('error', async (error) => {
|
||||
console.error('mongo error', error);
|
||||
logger.error('Mongo connection error', { error });
|
||||
});
|
||||
db.connection.on('connected', async () => {
|
||||
console.log('mongo connected');
|
||||
logger.info('Mongo connected');
|
||||
});
|
||||
db.connection.on('disconnected', async () => {
|
||||
console.error('mongo disconnected');
|
||||
logger.error('Mongo disconnected');
|
||||
});
|
||||
|
||||
await db.connect(url, {
|
||||
|
||||
Reference in New Issue
Block a user