Logger to enable structured logging in GKE powered projects
Allows printing structured logs to stdout
, stderr
for further action in Google Cloud platform. Given that log agent ingests logs from stdout
streams when running in GKE.

Precaution
A logger makes use of async_hooks
module which is currently experimental. However, the use of async_hooks
mechanism was at basic.
Installation
npm install --save gc-json-logger
yarn add gc-json-logger
View in Google Cloud Logging

Integration
const { Logger } = require('gc-json-logger');
const app = Logger.getLogger('app');
app.info('main');
Logger.getLogger().info('main');
Logger.getLogger('app').info('main');
setTimeout(() => {
const id = 'abc';
const logger = Logger.getLogger(id);
logger.info('context');
Logger.getLogger().info('context');
Logger.getLogger(id).info('context');
const custom = Logger.getLogger('custom');
custom.info('context');
});