Node.js Library Documentation

To simplify adding JustLog.IT logging into your Node.js applications we built a wrapper library.

Getting Started

Follow these steps to get our node.js library installed and running in your node.js application.

1. Install the node.js library
npm install justlogit --save
2. Reference the logging library
var Logger = require('justlogit');
3. Create a global logging instance
global.logger = new Logger('token');
Setting a global instance allows you to automatically reference the logging library from anywhere in your application using the syntax: global.logger.logError(obj);

Methods

This is the list of methods on the logging interface you can call to store values from your running web application.

MethodParametersDescription
logPerformance
  • method - the name of the method being tracked
  • timing - the number of milliseconds the action took
  • user - (optional) a user marker
  • details - (optional) any additional details for the log entry
Logs a performance record. Performance is calculated by taking the start and end timestamps (Date objects) and getting the millisecond difference between them.
logEvent
  • name - the name of the event
  • description - (optional) any additional details about the event
  • user - (optional) a user marker
Logs an event occurrence for the application.
logError
  • err - the error object caught in your try/catch block. This should be a fully populated object with all the fields set up, including a user marker if you need that.
Logs the details of an error. The error object is expected to have the default error object properties (message and stack)
logInformation
  • method - the name of the method being tracked
  • user - (optional) a user marker
  • details - (optional) any additional details for the log entry
Writes an information log entry into the system. These are useful to provide context to other entries, especially errors.

How it Works

The node library is designed to be as light-weight as possible. To that end all the methods listed above employ "fira and forget" execution. You call the method and it executes asynchronously but the do not have a callback method to return results. So just call the method with the required parameters and let your code continue executing. That does make it impossible to use the logging to control code execution flow but that has not been a problem so far.

This library uses the standard http(s) libraries that come with node to execute the calls. The error logging executes a POST to the log collector. The other 3 methods execute a GET request.

close
Get started with two months free.