{"_id":"@amplication/logging-utils","_rev":"3-6fe66565aa62d4fbc956f2612762cb97","name":"@amplication/logging-utils","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@amplication/logging-utils","version":"0.0.1","author":{"url":"https://amplication.com","name":"Amplication","email":"contact@amplication.com"},"_id":"@amplication/logging-utils@0.0.1","maintainers":[{"name":"amplication-bot","email":"engineering@amplication.com"},{"name":"mulygottlieb","email":"muly@amplication.com"},{"name":"levivannoort","email":"vanNoort.levi@protonmail.com"},{"name":"overbit","email":"daniele.iasella@gmail.com"},{"name":"morhag","email":"mor@amplication.com"},{"name":"amitbarletz","email":"amit@amplication.com"},{"name":"yuvalhazaz","email":"hazaz.yuval@gmail.com"}],"dist":{"shasum":"db7bfb54754f7846f13b4adb51aeef87f2de9da0","tarball":"https://registry.npmjs.org/@amplication/logging-utils/-/logging-utils-0.0.1.tgz","fileCount":14,"integrity":"sha512-n64Pzx4JL7RVFJApIgzcDrsRA4If3dMo5a9wn+K7ojlWSlcXCRTGrbW/mxzXbw+sG0mRnqPtxM1gdLW38mJtKA==","signatures":[{"sig":"MEUCIQCjYE5xKL8E394s36c1mZLgzhCBiHKpYQJjO6ZEDi6HOAIgMaWZ0iqy2cGxdu6bZZlXp/L1efCP2cJtLQpkgcTRhgo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13667},"main":"./src/index.js","type":"commonjs","types":"./src/index.d.ts","gitHead":"1e2677e3f850375217bffeec53186b4c4c35ddcd","_npmUser":{"name":"mulygottlieb","email":"muly@amplication.com"},"deprecated":"deprecated","_npmVersion":"9.8.1","description":"This library supplies a logger for Amplication Services","directories":{},"_nodeVersion":"18.18.0","dependencies":{"util":"0.12.5","logform":"2.5.1","winston":"3.8.2","@types/node":"18.14.2","triple-beam":"1.4.1","@types/triple-beam":"^1.3.2"},"_hasShrinkwrap":false,"peerDependencies":{"tslib":"1.14.1"},"_npmOperationalInternal":{"tmp":"tmp/logging-utils_0.0.1_1724767015074_0.23624253435818332","host":"s3://npm-registry-packages"}}},"time":{"created":"2024-08-27T13:56:54.952Z","modified":"2024-09-09T13:32:27.445Z","0.0.1":"2024-08-27T13:56:55.228Z"},"author":{"url":"https://amplication.com","name":"Amplication","email":"contact@amplication.com"},"description":"This library supplies a logger for Amplication Services","maintainers":[{"email":"engineering@amplication.com","name":"amplication-bot"},{"email":"muly@amplication.com","name":"mulygottlieb"},{"email":"vanNoort.levi@protonmail.com","name":"levivannoort"},{"email":"mor@amplication.com","name":"morhag"},{"email":"hazaz.yuval@gmail.com","name":"yuvalhazaz"}],"readme":"# util-logging\n\nThis library was generated with [Nx](https://nx.dev).\n\n## Building\n\nRun `nx build util-logging` to build the library.\n\n## Running unit tests\n\nRun `nx test util-logging` to execute the unit tests via [Jest](https://jestjs.io).\n\n\n## Getting started\n\n### Logging in libraries\n\nLibraries should always log without relying on a logger framework. \nIn order to do so, libraries should rely on the ILogger interface and any service/application will pass the proper logger class. \n\n```ts\n// library.class.ts\nimport { ILogger } from \"@amplication/util/logging\";\n\nexport class CakeFactory {\n    constructor(private readonly logger: ILogger){}\n\n    printInLog(message: string){\n        this.logger.info(message)\n        this.logger.error(message, new Error())\n    }\n}\n```\n\n### Logging in services / applications\n\nIn your microservices, import the logger module and consume it in your root module.\n\n```ts\n// module.ts\n\nimport { Logger } from '@amplication/util/logging';\n\nconst logger = new Logger ({\n  isProduction: true,\n  component: \"component-name\",\n  logLevel: LogLevel.Warn\n})\n\nconst logMe = () => {\n    logger.info(\"An info log message\", { other: { value: 1 }})\n    // ....\n}\n```\n\nThe minimum log level can be configured also with the `LOG_LEVEL` environment variable, instead of the `logLevel: LogLevel.Warn`, to one of the following values:\n- `debug`\n- `info`\n- `warn`\n- `error`\n\n\n## Testing utilsutils\n\nA mocked provider can be used in unit tests. \nThe following example explain how to use it\n\n```ts\n/// myservice.spec.ts\n\nimport { MockedLogger } from \"@amplication/util/logging/test-utils\";\n\n//...\nit('', () => {\n    const target = new Service(MockedLogger);\n})\n//...\n```","readmeFilename":"README.md"}