项目作者: listepo

项目描述 :
Sails hook for Sentry(raven-node)
高级语言: JavaScript
项目地址: git://github.com/listepo/sails-hook-sentry.git
创建时间: 2015-04-17T21:06:59Z
项目社区:https://github.com/listepo/sails-hook-sentry

开源协议:

下载


sails-hook-sentry

Sails JS hook to log errors and stack traces in Sentry from within your Sails.js applications.

npm version
Dependency Status
devDependency Status

Installation

npm install sails-hook-sentry

Usage

  • requires at least sails >= 0.11*

Configuration

By default, configuration lives in sails.config.sentry. The configuration key (sentry) can be changed by setting sails.config.hooks['sails-hook-sentry'].configKey.

Example

  1. // [your-sails-app]/config/sentry.js
  2. module.exports.sentry = {
  3. active: true,
  4. dsn: "{{ DSN }}",
  5. options: {
  6. logger: 'default',
  7. release: '1.0.0',
  8. environment: 'staging'
  9. }
  10. };
  1. // [your-sails-app]/api/controllers/UserController.js
  2. /**
  3. * UserController
  4. *
  5. * @description :: Server-side logic for managing users
  6. * @help :: See http://links.sailsjs.org/docs/controllers
  7. */
  8. module.exports = {
  9. find: function(req, res) {
  10. sails.sentry.captureMessage("Another message");
  11. res.ok('ok');
  12. }
  13. };

If you want to log 500 responses, add this to your responses/serverError.js

  1. // log error with sentry hook
  2. if(sails.sentry) sails.sentry.captureException(data);

sails.sentry alias for Raven client

More sails.sentry methods raven-node