This is a terrible hack. It will open an insecure method that writes to your database.
But it works.
I was very unpleasant when I was missing this feature, so I dug in the Velocity code to find out that they have a VelocityLogs collection that is publicly available. But you need to access it from your production, and not test the instance to see it in the web reporter.
So, it took me a while to enable Meteor CORS, but I finally managed - even for Firefox - to create a new route in IronRouter before the POST log message. (CORS might be better with this sentence - but you really shouldn't disclose it anyway.)
For this you will need meteor add http .
Put outside of / tests:
if Meteor.isServer Router.route 'log', -> if @request.method is 'OPTIONS' @response.setHeader 'Access-Control-Allow-Origin', '*' @response.setHeader 'Access-Control-Allow-Methods', 'POST, OPTIONS' @response.setHeader 'Access-Control-Max-Age', 1000 @response.setHeader 'Access-Control-Allow-Headers', 'origin, x-csrftoken, content-type, accept' @response.end() return if @request.method is 'POST' logEntry = @request.body logEntry.level ?= 'unspecified' logEntry.framework ?= 'log hack' logEntry.timestamp ?= moment().format("HH:mm:ss.SSS") _id = VelocityLogs.insert(logEntry) @response.setHeader 'Access-Control-Allow-Origin', '*' @response.end(_id) return , where: 'server'
Inside tests/mocha/lib or similarly as a utility function:
@log = (message, framework, level) -> HTTP.post "http://localhost:3000/log", data: { message: message, framework: framework, level: level} (error) -> console.dir error
For coffee lovers: coffeescript.org > TRY NOW> Paste the code to convert> Get the good old JavaScript.
neo post modern
source share