bitbucket-logging

0.0.4 • Public • Published

Node BitBucket Logging

Node BitBucket Logging is a custom log issue handler that has been written with the purpose of auto-opening (and assigning) issues on BitBucket everytime something goes south with NodeJS code.

Useful for production deployments, where you want to track the issues directly from BitBucket, not from a dark server log file.

Node BitBucket Logging is smart enough to recognize similar errors, thus not opening blindly a new issue everytime.

Setup

  • Add bitbucket-logging to your package.json dependencies.

  • Then, require and configure the module using the code below:

bitbucket_logging = require('bitbucket-logging');
 
/* GitLab options */
bitbucket_logging.configure({
    //Required
    slug:"PROJECT_NAME",
    owner:"OWNER",
    username:"USERNAME",
    password:"PASSWORD",
 
    // Optional
    environment: 'production'           // The NodeJS environment in use, useful when you pre-process the NODE_ENV value
});
  • Then, when you need to handle an error, just call:
// Boom, the error variable value will be redirected to your Bitbucket issues tracker!
bitbucket_logging.handle(error, callback);
  • If you need to catch all unhandled errors (which is recommended!), use the following code:
process.on('uncaughtException', function(error) {
    var error_message = error.stack || error;
 
    // Log to console
    console.error('uncaughtException', error_message);
 
    // Pipe error to Bitbucket
    bitbucket_logging.handle(error_message, function{
        // Recommended: kill the NodeJS process (restart a clean one via forever)
        process.exit(1);
    });
});
  • Enjoy!

Notes

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.4
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.4
    2
  • 0.0.3
    1
  • 0.0.2
    1

Package Sidebar

Install

npm i bitbucket-logging

Weekly Downloads

4

Version

0.0.4

License

none

Last publish

Collaborators

  • baptistejamin