Nodejs Hipchat Logger - Get up to 100 messages every 5 minutes directly from your node app to a hipchat room.
A great tool to make development easier when running apps on remote environments.
Installation
npm install Node-Hipchat-Logger --save
Set-up
var HipLoggerObj = require('Node-Hipchat-Logger');
var hipLogger = new HipLoggerObj({
'room-name': '<hip-chat-room-id>', // room to send message to
'notify': true // optional notification alert to user when new message is sent to room - defaults is set to false
});
After instantiating the new object, you can call its info
, warning
and error
message functions.
Info message has colour set to gray
Warning message has colour set to yellow
Error message has colour set to red
Call the functions passing in the message
you wish to send to the room and function-name
from which the message originated.
// Sending a success message
var successMsg = 'Function has ended with success!';
hipLogger.info(successMsg, 'myCoolFunction');
// Sending a warning message
var warningMsg = 'Something has gone wrong! Watch out!';
hipLogger.warning(warningMsg, 'checkingFunction');
// Sending an error message
var errorMsg = 'There was an error with running your function!';
// Or you can send an error object
var errorMsg = new Error('There was an error with running your function!');
hipLogger.error(errorMsg, 'errorFunction');
How the module works
The module will write to a config file that is set per project in the module's directory. On first instantiation of a logger object,
Node-Hipchat-Logger
will check for the existence of a hip-chat access token in the config.json
file. If an access token already exists,
this one is used for all your requests to the hip-chat api. If there is no access token, Node-Hipchat-Logger
will issue a request to
get the token from hip-chat node integartion app
to retrieve a valid access token and then store it in the config.json
file for the user.