mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-24 22:03:54 +00:00
4.8.6 fix (#1963)
* feat: log store * fix: full text search match query * perf: mongo schema import, Avoid duplicate import
This commit is contained in:
10
packages/service/common/system/log/constant.ts
Normal file
10
packages/service/common/system/log/constant.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
export enum LogLevelEnum {
|
||||
debug = 0,
|
||||
info = 1,
|
||||
warn = 2,
|
||||
error = 3
|
||||
}
|
||||
|
||||
export enum LogSignEnum {
|
||||
slowOperation = 'slowOperation'
|
||||
}
|
27
packages/service/common/system/log/schema.ts
Normal file
27
packages/service/common/system/log/schema.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { getMongoModel, Schema } from '../../../common/mongo';
|
||||
import { SystemLogType } from './type';
|
||||
import { LogLevelEnum } from './constant';
|
||||
|
||||
export const LogCollectionName = 'system_logs';
|
||||
|
||||
const SystemLogSchema = new Schema({
|
||||
text: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
level: {
|
||||
type: String,
|
||||
required: true,
|
||||
enum: Object.values(LogLevelEnum)
|
||||
},
|
||||
time: {
|
||||
type: Date,
|
||||
default: () => new Date()
|
||||
},
|
||||
metadata: Object
|
||||
});
|
||||
|
||||
SystemLogSchema.index({ time: 1 }, { expires: '15d' });
|
||||
SystemLogSchema.index({ level: 1 });
|
||||
|
||||
export const MongoLog = getMongoModel<SystemLogType>(LogCollectionName, SystemLogSchema);
|
9
packages/service/common/system/log/type.d.ts
vendored
Normal file
9
packages/service/common/system/log/type.d.ts
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { LogLevelEnum, LogSignEnum } from './constant';
|
||||
|
||||
export type SystemLogType = {
|
||||
_id: string;
|
||||
text: string;
|
||||
level: LogLevelEnum;
|
||||
time: Date;
|
||||
metadata?: Record<string, any>;
|
||||
};
|
Reference in New Issue
Block a user