Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including gc-json-logger with all npm packages installed. Try it out:

/* eslint-disable @typescript-eslint/no-var-requires */ const { Logger } = require('gc-json-logger'); const { createServer } = require('http'); let job = 0; function scheduleJob() { /** * 4) Retrieving a context logger */ const logger = Logger.getLogger(); /** * 5) Logs with job id from the parent */ logger.info('scheduling job'); setTimeout(() => { /** * 6) Logs with job id from the parent */ logger.info('job done'); }, 3000); } const server = createServer((_, res) => { job++; /** * 1) Setting a context logger using job id */ const logger = new Logger(job); Logger.runWith(logger, () => { /** * 2) Logs with with job id */ logger.info('creating a new job'); /** * 3) Calls another function that uses the context */ scheduleJob(); res.setHeader('content-type', 'application/json'); res.end(JSON.stringify({ id: job, status: 'scheduled' })); }); }); server.listen(8080);

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

gc-json-logger v2.1.0

Log JSON entries to stdout/stderr to be queried in Google Cloud Monitoring

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free