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
790 B
35 lines
790 B
// log.js
|
|
// Copyright (C) 2022 DTP Technologies, LLC
|
|
// License: Apache-2.0
|
|
|
|
'use strict';
|
|
|
|
const mongoose = require('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' },
|
|
component: {
|
|
logId: { type: String, required: true, index: 1 },
|
|
index: { type: String, required: true },
|
|
className: { 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 },
|
|
});
|
|
|
|
module.exports = (conn) => {
|
|
return conn.model('Log', LogSchema);
|
|
};
|