DTP Base provides a scalable and secure Node.js application development harness ready for production service.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

35 lines
739 B

// log.js
// Copyright (C) 2024 DTP Technologies, LLC
// All Rights Reserved
'use strict';
import mongoose from 'mongoose';
const Schema = mongoose.Schema;
const LOG_LEVEL_LIST = [
'debug',
'info',
'warn',
'alert',
'error',
'crit',
'fatal',
];
const LogSchema = new Schema({
created: { type: Date, default: Date.now, required: true, index: -1, expires: '7d' },
componentName: { type: String, required: true, index: 1 },
level: { type: String, enum: LOG_LEVEL_LIST, required: true, index: true },
message: { type: String },
metadata: { type: Schema.Types.Mixed },
});
LogSchema.index({
level: 1,
componentName: 1,
}, {
name: 'log_level_component_idx',
});
export default mongoose.model('Log', LogSchema);