44 lines
1.0 KiB
JavaScript
44 lines
1.0 KiB
JavaScript
import { Meteor } from 'meteor/meteor';
|
|
import { Mongo } from 'meteor/mongo';
|
|
|
|
// The logging tool is primarily for managing administrative functions such that administrators can view the app logs and issue commands that might generate administrative logging.
|
|
|
|
Meteor.log = new Logger();
|
|
Logs = new Mongo.Collection('Logs');
|
|
|
|
let logMongo = new LoggerMongo(Meteor.log, {
|
|
collection: Logs
|
|
});
|
|
logMongo.enable({
|
|
enable: true,
|
|
client: false, /* Client calls are not executed on the client. */
|
|
server: true /* Calls from the client will be executed on the server. */
|
|
});
|
|
|
|
if(Meteor.isServer) {
|
|
Logs._ensureIndex({'date': 1}, {expireAfterSeconds: 86400});
|
|
Meteor.publish('logs', function() {
|
|
return Logs.find({}, {limit: 10000});
|
|
});
|
|
Meteor.methods({
|
|
clearLogs: function() {
|
|
return Logs.remove({}, function(err) {
|
|
if(err) Meteor.log.error(err);
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
Logs.allow({
|
|
insert: () => false,
|
|
update: () => false,
|
|
remove: () => false
|
|
});
|
|
|
|
Logs.deny({
|
|
insert: () => true,
|
|
update: () => true,
|
|
remove: () => true
|
|
});
|
|
|
|
export default Logs; |