@houseid/gcp-logging-helper
v1.0.7
Published
Helper for writing structured JSON log messages to stdout/stderr compatible with Google Cloud Logging and Google Error Reporting
Downloads
7
Readme
@houseid/gcp-logging-helper
Example:
// Initialize:
const { createLogger } = require('@houseid/gcp-logging-helper')({
projectId: () => process.env.CLOUD_PROJECT_ID,
sourceReference: () => ({
repository: 'https://github.com/House-ID/gcp-logging-helper',
revisionId: process.env.GIT_COMMIT_SHA // set GIT_COMMIT_SHA=$COMMIT_SHA in Cloud Build
}),
serviceContext: () => ({ resourceType: 'cloud_run_revision' }),
initialData: req => ({
req: {
params: req.params,
query: req.query
}
})
});
// In API:
const logger = createLogger(req);