Created
June 24, 2015 10:54
-
-
Save rhyslbw/8bbea8d914ee6799ca47 to your computer and use it in GitHub Desktop.
Very simple way to log events into a 1GB capped collection on the current Meteor server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Logs = new Mongo.Collection 'logs' | |
# Collection capped at 1GB and | |
# http://docs.mongodb.org/manual/core/capped-collections/ | |
# https://github.com/meteor/meteor/blob/07b6a2245a1e091830844881e7376c38adda3592/packages/mongo/collection.js | |
Logs._createCappedCollection 1000000000, 8000000 | |
Meteor.methods | |
'log': (source, event) -> | |
@unblock() | |
Logs.insert | |
source: source, | |
event: event, | |
time: new Date | |
console.log '[%s] %s', source, event |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment