{"_id":"@aurora-is-near/gcp-logger","_rev":"2-7046c625a54312c10097fc82e775b300","name":"@aurora-is-near/gcp-logger","dist-tags":{"latest":"1.0.3"},"versions":{"1.0.3":{"name":"@aurora-is-near/gcp-logger","version":"1.0.3","author":{"name":"Alex Mendes"},"license":"UNLICENSED","_id":"@aurora-is-near/gcp-logger@1.0.3","maintainers":[{"name":"chris-aurora","email":"chris.gutkowski@aurora.dev"},{"name":"aurorasec","email":"security@aurora.dev"},{"name":"aurealis","email":"diego.figueroa@aurora.dev"},{"name":"alexmendes","email":"alexanderhmendes@gmail.com"}],"dist":{"shasum":"ebafd63c09076388797873c06ccab6d72046a509","tarball":"https://registry.npmjs.org/@aurora-is-near/gcp-logger/-/gcp-logger-1.0.3.tgz","fileCount":26,"integrity":"sha512-bFsoHjVu8QbTHk7YPExB2LmmtFdiqZCBIBLOBFCjySaIARbVQ3W4/k5t5bJhh9GzWK0pEfiMHAYG29ATURnyBw==","signatures":[{"sig":"MEYCIQDk+An2c2Kwqsetl8VAI0PrejUXbWRaFXWBTD/tqMTRgwIhAJhkk7FzRvaKGP+QES3cKgYwexEaZ15UA78ax+cPEKjE","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":29639},"main":"dist/index.js","husky":{"hooks":{"commit-msg":"commitlint -E HUSKY_GIT_PARAMS"}},"types":"./dist/index.d.ts","engines":{"node":">=20.9.0"},"gitHead":"c597b430f3654f8a7c6298606c060147fd0cf010","scripts":{"lint":"eslint . --ext .js,.ts","test":"jest","build":"tsc","clean":"rimraf dist","prebuild":"yarn clean","typecheck":"tsc --noEmit"},"_npmUser":{"name":"alexmendes","actor":{"name":"alexmendes","type":"user","email":"alexanderhmendes@gmail.com"},"email":"alexanderhmendes@gmail.com"},"_npmVersion":"10.8.1","description":"A logger for Node that integrates with Google Cloud Platform","directories":{},"_nodeVersion":"22.17.0","dependencies":{"winston":"^3.13.0","deepmerge":"^4.3.1","winston-console-format":"^1.0.8","@google-cloud/logging-winston":"^6.0.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.0.0","husky":"^9.0.11","eslint":"^8.57.0","rimraf":"^3.0.2","ts-jest":"^29.1.0","prettier":"^3.2.5","mock-http":"^1.1.0","typescript":"^5.1.0","@babel/core":"^7.17.10","@types/jest":"^29.0.0","@types/node":"^17.0.31","@commitlint/cli":"^19.3.0","semantic-release":"^24.0.0","@babel/preset-env":"^7.16.11","@babel/preset-typescript":"^7.16.7","@aurora-is-near/eslint-config":"^1.5.3","@babel/plugin-transform-runtime":"^7.17.0","@commitlint/config-conventional":"^19.2.2","@aurora-is-near/semantic-release-config":"^1.5.3"},"_npmOperationalInternal":{"tmp":"tmp/gcp-logger_1.0.3_1752087241633_0.16164737623338143","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2025-07-09T18:54:01.561Z","modified":"2026-05-12T13:01:30.667Z","1.0.3":"2025-07-09T18:54:01.843Z"},"author":{"name":"Alex Mendes"},"license":"UNLICENSED","description":"A logger for Node that integrates with Google Cloud Platform","maintainers":[{"email":"chris.gutkowski@aurora.dev","name":"chris-aurora"},{"email":"security@aurora.dev","name":"aurorasec"},{"email":"alexanderhmendes@gmail.com","name":"alexmendes"}],"readme":"# GCP Logger\n\nA logger for Node that integrates with Google Cloud Platform.\n\nThis repository enforces semantic commit messages. For more details and examples\nsee the [Conventional Commits Specification](https://www.conventionalcommits.org).\n\n## Installation\n\n```text\nyarn add @aurora-is-near/gcp-logger\n```\n\n## Usage\n\n```ts\nimport { createLogger } from 'aurora-is-near/gcp-logger';\n\nconst logger = createLogger();\n\nlogger.debug('Something happened');\nlogger.info('Something else happened');\nlogger.warn('Something quite bad happened, but I can recover.');\nlogger.error('Something really bad happened');\nlogger.error(new Error('I also accept error objects'));\n```\n\n## HTTP requests\n\nTo include additional information about an HTTP request you can include a\nrequest object when calling `createLogger()`. This object should be a Node\n[`IncomingMessage`](https://nodejs.org/api/http.html#class-httpincomingmessage),\nor child or an `IncomingMessage`, such as the request object passed to a Google\nCloud Function, for example:\n\n```ts\nconst requestHandler = (req, res) => {\n  const logger = createLogger({ req });\n\n  logger.debug('Something happened');\n}\n```\n\nTo include additional information about the response you can use the `set`\nfunction, as follows:\n\n```ts\nlogger.set('httpRequest', {\n  status: 500,\n  responseSize: '4200',\n});\n```\n\nSee [HttpRequest](https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#httprequest)\nfor more details.\n\n## Context\n\nIf you want to set some arbitrary context that should be attached to all\nsubsequent log messages you can do so like this:\n\n```ts\nlogger.set('context', {\n  user: {\n    name: 'Joe Bloggs',\n  },\n  auth: {\n    authenticated: true,\n  },\n});\n```\n\nIf you want to append to some previously set context you can do so like this:\n\n```ts\nlogger.append('context', {\n  user: {\n    age: 37,\n  },\n});\n```\n\nUsing the two snippets above as an example, this would result in all subsequent\nlog messages including the data:\n\n```json\n{\n  \"jsonPayload\": {\n    \"user\": {\n      \"name\": \"Joe Bloggs\",\n      \"age\": 37\n    },\n    \"auth\": {\n      \"authenticated\": true\n    }\n  }\n}\n```\n\nNote that when appending to the context objects will be merged, primitive values\nand arrays will be replaced.\n\n## Log Levels\n\nA logging function is provided for each of the following levels\n(shown in ascending order):\n\n- `debug`: This is the level for something entirely ordinary going on, like a\nsuccessful response being sent. These may be quite spammy, with multiple entries\npresenting overlapping information.\n- `info`: This also has a neutral connotation, but represents something more rare,\nlike a major state change. It could for example also be used for printing the\nresults of a timed job, or usage statistics.\n- `warn`: This is for unusual conditions that are recoverable but may cause\nnuisances, or later a more severe problem. For example, it could be used for\noptional requests failing, or when an inconsistent but uncritical data state is\ndetected.\n- `error`: This is for a case where the application fails to do its main job. For\nexample, if a user request could not be served, and this cannot be attributed to\na client error.\n\nBy default, if `NODE_ENV=production` then logs at the `info` level and above\nwill be processed, otherwise all logs will be processed. You can control this\nmore specifically by setting the `logLevel` when calling `createLogger()`, for\nexample:\n\n```ts\ncreateLogger({ logLevel: 'warn' });\n```\n\nYou can also set the log level via the `LOG_LEVEL` environment variable, which\nmay be useful for enabling debug logs temporarily in a remote environment, for\nexample.\n","readmeFilename":"README.md"}