Skip to content

Instantly share code, notes, and snippets.

@rhyslbw
Created June 24, 2015 10:54
Show Gist options
  • Save rhyslbw/8bbea8d914ee6799ca47 to your computer and use it in GitHub Desktop.
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
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