datadog-logger
v1.0.2
Published
Datadog logger
Downloads
56
Readme
Datadog Logger (beta)
You've small project and wanna logging to cloud service, but do not wanna install graylog or another logging agent?
Store your logs at Datadog via datadog-logger
. It's simple.
Install
npm i datadog-logger
Create logger
import { DatadogLogger } from 'datadog-logger';
const log = new DatadogLogger({
logLevel: 'info',
apiKey: process.env.DATADOG_API_KEY,
allowStdout: true,
service: 'service-name',
source: 'script-name',
hostname: 'service-host',
tags: {
platform: 'node',
language: 'typescript',
},
});
Use
log.info('Hello world!');
log.warn('Warning!');
log.error('some error', new Error('bad code'));
log.debug('2 + 2 =', 2 + 2);
Look logs at Datadog
Options
| Name | Type | Required | Default | | ------------- | ------------- | :-------------:| -----:| | apiKey | string | Yes | null | | logLevel | string | No | 'info' | | service | string | No | 'nodejs-project' | | source | string | No | 'nodejs-script' | | tags | object | No | {} | | hostname | string | No | 'localhost' | | allowStdout | boolean | No | false | | stdoutOnly | boolean | No | false |