1.1.21 • Published 7 years ago
the-simple-log v1.1.21
simple-log: a cloud-based log for node
simple-log is the simple way to do logging on node. Debug your application from anywhere, whether it's running locally, in a docker container, or in a VPS in the cloud.
Table of Contents
Installation
npm install -S simple-logRequirements
You need to create an API Key and a Project on https://app.thesimplelog.com/
Usage
After setting up the simple object:
const options = { apiKey: 'your.api.key.here', projectName: 'My App' };
const simple = require('simple-log')(options);You can call simple.log or one of the convenience functions (simple.debug, simple.info, simple.warn, simple.error, simple.fatal)
Examples
Logging 101
'use strict';
const options = { apiKey: 'your.api.key.here', project: 'My App' };
const simple = require('simple-log')(options);
// since we're using simple.log, we have to pass the logging level ('info') ourselves
simple.log('info', 'Started application');
// helper functions perform the same action as simple.log('LEVEL', 'message')
simple.info('Initializing modules...');
simple.debug('Starting MySQL');
simple.debug('Starting Redis');Options
There are a number of options that can be set while initializing the simple object:
apiKey(required) - obtain via https://app.thesimplelog.com/project(required) - obtain via https://app.thesimplelog.com/transports(optional) - default value:["simple-api", "console"], allowable values:["simple-api", "console"]consoleFormat(optional) - default value:d h (i): m, allowable values can be seen here
Transports
There are two available transports, both are enabled by default:
simple-api- logs to The Simple App APIconsole- logs locally tostdout, just likeconsole.log
Output Formats
When logging to the console (using the console transport option and setting consoleFormat), you can specify the preferred format from the following options:
f: filenamel: line numberh: hostnamei: internal ipe: external ipd: datem: message