Permalink
Browse files

Adding query parser

  • Loading branch information...
mattrobenolt committed Mar 18, 2012
1 parent f839b93 commit c258308ffc70ac9672b1816c5d87640fb2bbb331
Showing with 31 additions and 2 deletions.
  1. +0 −1 README.md
  2. +11 −1 lib/parsers.js
  3. +20 −0 test/raven.parsers.js
View
@@ -95,4 +95,3 @@ app.listen(3000);
* More complete test coverage
* More comments in code
* More third party integration
- * Logging support for SQL
View
@@ -18,4 +18,14 @@ module.exports.parseError = function parseError(err, kwargs, cb) {
kwargs['culprit'] = (frames[0].filename || 'unknown file').replace(process.cwd()+'/', '')+':'+(frames[0]['function'] || 'unknown function');
cb(kwargs);
});
-};
+};
+
+module.exports.parseQuery = function parseQuery(query, engine, kwargs) {
+ kwargs = kwargs || {};
+ kwargs['message'] = query;
+ kwargs['sentry.interfaces.Query'] = {
+ query: query,
+ engine: engine
+ };
+ return kwargs;
+};
View
@@ -19,6 +19,26 @@ describe('raven.parsers', function(){
});
});
+ describe('#parseQuery()', function(){
+ it('should parse a query', function(){
+ var query = 'SELECT * FROM `something`';
+ var engine = 'mysql';
+ var parsed = raven.parsers.parseQuery(query, engine);
+ parsed['message'].should.equal('SELECT * FROM `something`');
+ parsed.should.have.property('sentry.interfaces.Query');
+ parsed['sentry.interfaces.Query'].query.should.equal('SELECT * FROM `something`');
+ parsed['sentry.interfaces.Query'].engine.should.equal('mysql');
+ });
+
+ it('should parse some text with kwargs', function(){
+ var parsed = raven.parsers.parseText('Howdy', {'foo': 'bar'});
+ parsed['message'].should.equal('Howdy');
+ parsed.should.have.property('sentry.interfaces.Message');
+ parsed['sentry.interfaces.Message'].message.should.equal('Howdy');
+ parsed['foo'].should.equal('bar');
+ });
+ });
+
describe('#parseError()', function(){
it('should parse plain Error object', function(done){
raven.parsers.parseError(new Error(), {}, function(parsed){

0 comments on commit c258308

Please sign in to comment.