{"_id":"@cultivo/gc-json-logger","_rev":"1-9c44f6924ed17e37d867a35a35101a2c","name":"@cultivo/gc-json-logger","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.0":{"name":"@cultivo/gc-json-logger","version":"0.0.0","license":"MIT","author":{"name":"Igor Korchagin","url":"https://github.com/igrek8"},"keywords":["logger","logging","monitoring","structured-logging","google-cloud"],"description":"Log JSON entries to stdout/stderr to be queried in Google Cloud Monitoring","main":"dist/index.js","types":"dist/index.d.ts","runkitExampleFilename":"runkit.js","homepage":"https://github.com/CultivoLand/gc-json-logger#readme","repository":{"type":"git","url":"git+https://github.com/CultivoLand/gc-json-logger.git"},"bugs":{"url":"https://github.com/CultivoLand/gc-json-logger/issues"},"prettier":"@igrek8/prettier-config","publishConfig":{"access":"public"},"release":{"extends":"@igrek8/semantic-release-config"},"jest":{"preset":"@igrek8/jest-preset"},"eslintConfig":{"extends":"@igrek8/eslint-config","env":{"node":true}},"commitlint":{"extends":["@commitlint/config-conventional"]},"scripts":{"clean":"rimraf dist","test":"jest","compile":"tsc -p tsconfig.build.json","build":"npm run clean && npm run compile","lint":"eslint \"**/*\"","format":"prettier --check \"**/*\"","docs":"typedoc build -o docs && typedoc publish -o docs"},"engines":{"node":">=14"},"dependencies":{"tslib":"^2"},"devDependencies":{"@commitlint/cli":"17.7.1","@commitlint/config-conventional":"17.7.0","@igrek8/eslint-config":"1.0.6","@igrek8/jest-preset":"1.0.11","@igrek8/prettier-config":"1.0.11","@igrek8/semantic-release-config":"1.0.11","@igrek8/tsconfig":"1.0.11","@igrek8/typedoc":"1.1.2","@types/node":"20.6.2","typescript":"4.9.5","jest":"29.7.0","prettier":"2.8.8","eslint":"8.49.0","rimraf":"5.0.1","tslib":"2.6.2"},"gitHead":"efb1e6aaf4ce0e62778c6179776b7dbbf63723c6","_id":"@cultivo/gc-json-logger@0.0.0","_nodeVersion":"16.17.0","_npmVersion":"8.15.0","dist":{"integrity":"sha512-AJkqv9gGcltaTsjCwt0KWEl2CkupDvTUWseBGDRqfUDWY/YVDNpdBnC+wNTUvpIKo3YhBQgtbcuTbZiXuvt6Wg==","shasum":"e1a66da94b25e2d131b2dc20b6f0eff988549ff4","tarball":"https://registry.npmjs.org/@cultivo/gc-json-logger/-/gc-json-logger-0.0.0.tgz","fileCount":4,"unpackedSize":7338,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDFR/BHhGyIn1RQTLd6i37/JslmdLz4GMY0eSFkG2ozqQIgdwgXWUATtFbtSG2wUq+lUgr1mJikZQ1gPhIzIFjwEgo="}]},"_npmUser":{"name":"neil.mcmillan","email":"neil.mcmillan@cultivo.land"},"directories":{},"maintainers":[{"name":"neil.mcmillan","email":"neil.mcmillan@cultivo.land"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/gc-json-logger_0.0.0_1695224476775_0.16259625331887406"},"_hasShrinkwrap":false},"0.0.1":{"name":"@cultivo/gc-json-logger","version":"0.0.1","license":"MIT","author":{"name":"Igor Korchagin","url":"https://github.com/igrek8"},"keywords":["logger","logging","monitoring","structured-logging","google-cloud"],"description":"Log JSON entries to stdout/stderr to be queried in Google Cloud Monitoring","main":"dist/index.js","types":"dist/index.d.ts","runkitExampleFilename":"runkit.js","homepage":"https://github.com/CultivoLand/gc-json-logger#readme","repository":{"type":"git","url":"git+https://github.com/CultivoLand/gc-json-logger.git"},"bugs":{"url":"https://github.com/CultivoLand/gc-json-logger/issues"},"prettier":"@igrek8/prettier-config","publishConfig":{"access":"public"},"release":{"extends":"@igrek8/semantic-release-config"},"jest":{"preset":"@igrek8/jest-preset"},"eslintConfig":{"extends":"@igrek8/eslint-config","env":{"node":true}},"commitlint":{"extends":["@commitlint/config-conventional"]},"scripts":{"clean":"rimraf dist","test":"jest","compile":"tsc -p tsconfig.build.json","build":"npm run clean && npm run compile","lint":"eslint \"**/*\"","format":"prettier --check \"**/*\"","docs":"typedoc build -o docs && typedoc publish -o docs"},"engines":{"node":">=14"},"dependencies":{"tslib":"^2"},"devDependencies":{"@commitlint/cli":"17.7.1","@commitlint/config-conventional":"17.7.0","@igrek8/eslint-config":"1.0.6","@igrek8/jest-preset":"1.0.11","@igrek8/prettier-config":"1.0.11","@igrek8/semantic-release-config":"1.0.11","@igrek8/tsconfig":"1.0.11","@igrek8/typedoc":"1.1.2","@types/node":"20.6.2","typescript":"4.9.5","jest":"29.7.0","prettier":"2.8.8","eslint":"8.49.0","rimraf":"5.0.1","tslib":"2.6.2"},"gitHead":"bf7296fd63b0f4e0978c99f600b61a5f309508ef","_id":"@cultivo/gc-json-logger@0.0.1","_nodeVersion":"16.17.0","_npmVersion":"8.15.0","dist":{"integrity":"sha512-OMDLlqnkSx481OYDFyw5/H8vIk0VDPWspoqoxw7YOXr67eQ1dT7Jq0TJEJz8ck/zPR2jJoTXnQv75QpiH5qzMA==","shasum":"a5121f195fcaada9d95ef57dc0f7a41d642020a8","tarball":"https://registry.npmjs.org/@cultivo/gc-json-logger/-/gc-json-logger-0.0.1.tgz","fileCount":68,"unpackedSize":62957,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHJzgmQsRi6CZ2n+vWPsNcUx4zOPtkqvG7cJkXaaXiMbAiEAge6pL43DQuNKBI0avolijSz1b+eOd/5oiDZO4KKfejA="}]},"_npmUser":{"name":"neil.mcmillan","email":"neil.mcmillan@cultivo.land"},"directories":{},"maintainers":[{"name":"neil.mcmillan","email":"neil.mcmillan@cultivo.land"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/gc-json-logger_0.0.1_1695225120926_0.032995994368181014"},"_hasShrinkwrap":false}},"time":{"created":"2023-09-20T15:41:16.671Z","0.0.0":"2023-09-20T15:41:16.975Z","modified":"2023-09-20T15:52:01.372Z","0.0.1":"2023-09-20T15:52:01.126Z"},"maintainers":[{"name":"neil.mcmillan","email":"neil.mcmillan@cultivo.land"}],"description":"Log JSON entries to stdout/stderr to be queried in Google Cloud Monitoring","homepage":"https://github.com/CultivoLand/gc-json-logger#readme","keywords":["logger","logging","monitoring","structured-logging","google-cloud"],"repository":{"type":"git","url":"git+https://github.com/CultivoLand/gc-json-logger.git"},"author":{"name":"Igor Korchagin","url":"https://github.com/igrek8"},"bugs":{"url":"https://github.com/CultivoLand/gc-json-logger/issues"},"license":"MIT","readme":"# What's new in this fork?\nAdded a `setFormatter` static function to `Logger`. This can be useful for developers running the application \nlocally and presenting logs in a more developer-friendly form than the default stringified JSON.\n\n# Logger for [Structured Logging](https://cloud.google.com/logging/docs/structured-logging) with [Asynchronous Context Tracking](https://nodejs.org/api/async_context.html#class-asynclocalstorage) (Stability: 2 - Stable)\n\nAllows printing logs to `stdout`, `stderr` for further action in Google Cloud platform. Given that log agent ingests logs from `stdout` streams when running in GKE.\n\n[![NPM](https://badgen.net/npm/v/gc-json-logger)](https://www.npmjs.com/gc-json-logger)\n[![Coverage](https://codecov.io/gh/igrek8/gc-json-logger/branch/main/graph/badge.svg)](https://codecov.io/gh/igrek8/gc-json-logger)\n![Health](https://badgen.net/github/checks/igrek8/gc-json-logger)\n![License](https://badgen.net/github/license/igrek8/gc-json-logger)\n[![Runkit](https://badgen.net/badge/runkit/playground/cyan)](https://npm.runkit.com/gc-json-logger)\n\n## Installation\n\n```bash\nnpm install --save gc-json-logger\n\nyarn add gc-json-logger\n```\n\n## View in Google Cloud Logging\n\n![Google Cloud Logging](./media/google-cloud-logging.png)\n\n## Integration\n\n```js\nconst { Logger } = require('gc-json-logger');\nconst { createServer } = require('http');\n\nlet job = 0;\n\nfunction scheduleJob() {\n  /**\n   * 4) Retrieving a context logger\n   */\n  const logger = Logger.getLogger();\n\n  /**\n   * 5) Logs with job id from the parent\n   */\n  logger.info('scheduling job');\n\n  setTimeout(() => {\n    /**\n     * 6) Logs with job id from the parent\n     */\n    logger.info('job done');\n  }, 3000);\n}\n\nconst server = createServer((_, res) => {\n  job++;\n\n  /**\n   * 1) Setting a context logger using job id\n   */\n  const logger = new Logger(job);\n  Logger.runWith(logger, () => {\n    /**\n     * 2) Logs with with job id\n     */\n    logger.info('creating a new job');\n\n    /**\n     * 3) Calls another function that uses the context\n     */\n    scheduleJob();\n\n    res.setHeader('content-type', 'application/json');\n    res.end(JSON.stringify({ id: job, status: 'scheduled' }));\n  });\n});\n\nserver.listen(8080);\n```\n\n```jsonc\n{\n  \"severity\": \"INFO\",\n  \"time\": \"2022-12-03T10:00:00.000Z\",\n  \"message\": \"creating a new job\",\n  \"logging.googleapis.com/operation\": { \"id\": 1 } // <- always includes context id\n}\n\n{\n  \"severity\": \"INFO\",\n  \"time\": \"2022-12-03T10:00:00.398Z\",\n  \"message\": \"scheduling job\",\n  \"logging.googleapis.com/operation\": { \"id\": 1 } // <- always includes context id\n}\n\n{\n  \"severity\": \"INFO\",\n  \"time\": \"2022-12-03T10:00:01.000Z\",\n  \"message\": \"job done\",\n  \"logging.googleapis.com/operation\": { \"id\": 1 } // <- always includes context id\n}\n```\n\n## Usage\n\nThe various logging methods (`debug`, `info`, `notice`, etc.) require two parameters. The first parameter is intended for a human-readable string, while the second parameter captures context (such as JSON objects with circular references).\n\nExample of **incorrect** use: :x:\n\n```ts\nthis.logger.log(Severity.DEBUG, JSON.stringify(someObject));\n```\n\nExample of **correct** use: :white_check_mark:\n\n```ts\nthis.logger.debug('received tickets', someObject);\n```\n","readmeFilename":"README.md"}