rover-mdd
v0.0.11
Published
Rover MDD
Downloads
7
Readme
Rover MDD
A logging and monitoring library for GCP/Stackdriver
Installation (client)
Use npm:
npm install -s rover-mdd
Logging
Basic Usage
To log something, you simply import the logger
and use the syntax below.
Note: this function is not fully typed yet (issue here)
To provide a payload, just add a second argument.
Levels include: silly, debug, verbose, info, warn, error
where only info, warn, error
will be used
If you require a different config, see "Advanced Usage" below
import { logger } from 'rover-mdd';
...
logger.info('Simple log');
logger.warn('With payload', { foo: 'bar', stuff: 123})
Advanced Usage
We are also exporting a logger, which allows you to specify the minimal log level it passes on:
import { advancedLogger } from 'rover-mdd';
// if you need a logger that only passes on errors
const myToughLogger = advancedLogger('error');
logger.warn('silence...'); // won't be passed
logger.error('BOOM');
Monitoring
To monitor, use the metric builder to create a metric, by providing a service, a metric name and the GCP projectId.
This will return a function that expects one or many labels and a number
as metric.
This functionality will be extended later. For now only numbers are expected. The monitoring will be timeseries based, where the timestamp etc is added in the library.
import { metricBuilder } from 'rover-mdd';
...
// create a metric
const myMetric = metricBuilder({
service: 'Matterhorn',
metricName: 'PhotosTaken',
projectId: 'staging-rover',
});
...
myMetric({ labels: {someTag: 'label', somethingElse: 'anotherLabel'}, metric: 123})
Development
- Clone
npm install
- develop
- increase version (not automated as of now)
npm run publish