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 yourapplication 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 endtimestamps (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 fullypopulated 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 thedefault 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 otherentries, especially errors.
setAppActionInterval
  • seconds - the collection interval for the app actions
Sets the collection interval for the app actions. This interval determines how long the app actions will be collected before they are logged to the JustLog.IT system.
logAppAction
  • name - the name of the action being tracked
  • pid - (optional) the process identifier the action occurred on
  • timing - (optional) execution time for the action in milliseconds. If you want to track the timings (min, max, avg) for this action you need to supply this value.
Logs an app action instance. These will be collected for the given interval and then automatically logged as a batch.

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 executesa POST to the log collector. The other 3 methods execute a GET request.

close
Sign up to get started