0.0.1 • Published 7 years ago

@immutabl3/error-logger v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
7 years ago

error-logger

js browser-to-server error logger

npm install @immutabl3/error-logger

About

Uses stacktrace-js and mailgun-js to catch and email errors from client-side applications.

Browser

const errorLogger = require('@immutable/error-logger/browser');

const logger = errorLogger({
	// if true, errors won't be reported to the server
	// they will instead be logged to the console
	debug: false,
	// url to POST the log
	url: '/error'
});

// listen for any uncaught errors on the window
logger.listen();

// log an error manually by passing an Error object
logger.log(error, [level = 'debug']);

Express

const errorLogger = require('@immutable/error-logger/express');

const logger = errorLogger({
	// mailgun configuration
	mailgunKey: '',
	mailgunDomain: '',
	// from email address
	from: ''
	// to email address
	to: ''
	// [optional] string to place in the subject line
	subject: ''
});

app.post('/error', logger);

License

MIT