JavaScript

Create project

If you have not done so already, you will need to create a new Project. You can do it on Projects page in Logstats application (more).

Installation

1. Download library from github

2. Include script in HTML

<script src="path/to/logstats.min.js"></script>

Basic usage

First you need to get project token from Projects page in Logstats application. This token will be used to associate logger with given project.
Then you need URL to which will logger send data. It consists of URL to which you have uploaded Logstats application and suffix "/api". For example: "http://your-domain.com/logstats/api"

Log record consists of message and context. Message should describe event, context is optional and can contain data associated with event. For example, for purchase it can be user, which made the purchase, purchased product, or price. For data in context, Logstats application enables filtering and charts visualization.

var webUrl = 'http://your-domain.com/logstats/api';
var projectToken = 'myProjectToken';
var logger = new LogstatsLogger(webUrl, projectToken);

logger.alert('Could not connect to database');
logger.info('purchase', {
	user : {
		name : 'Marek',
		age : 20
	},
	price : 50.0
});
// all available levels are: debug, info, notice, warning, error, alert, critical, emergency