GCF Logger
This is a reusable logger for Google Cloud Functions that includes a traceable ID
Installation
npm install gcf-logger
yarn add gcf-logger
Usage
Node
const logger = ;// instantiate: assume ENV var API_KEY existsconst log =name: "my-feature"level: 2;// usinglog;
Typescript
;// instantiate: with just name;// pass in reference (requestId) for traceabilitylog.init;// usinglog.info`Something happened`;
Output
The output is sent to stdout as a stringified JSON object, making it easier to consume in document storage for later analysis.
{
ts: '2018-01-01T08:32:30.858Z',
msg: 'Something happened',
ref: 'http-12345',
type: 'info',
level: 2,
host: 'localhost',
pid: 12345
}
Testing
npm test
npm run coverage
Build (compiles Typescript to JS)
npm run build