update tsconfig

This commit is contained in:
Philipp Kunz 2024-04-14 13:39:41 +02:00
parent d1284024d5
commit 9476ad8129
4 changed files with 90 additions and 63 deletions

View File

@ -5,16 +5,24 @@
"githost": "code.foss.global", "githost": "code.foss.global",
"gitscope": "push.rocks", "gitscope": "push.rocks",
"gitrepo": "logcontext", "gitrepo": "logcontext",
"description": "enrich logs with context", "description": "A module to enrich logs with context, featuring async log contexts and scope management.",
"npmPackagename": "@push.rocks/logcontext", "npmPackagename": "@push.rocks/logcontext",
"license": "MIT" "license": "MIT",
"keywords": [
"logging",
"context enrichment",
"async log contexts",
"scope management",
"typescript",
"nodejs"
]
} }
}, },
"npmci": { "npmci": {
"npmAccessLevel": "public", "npmAccessLevel": "public",
"npmGlobalTools": [] "npmGlobalTools": []
}, },
"tsdocs": { "tsdoc": {
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n" "legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
} }
} }

View File

@ -1,7 +1,7 @@
{ {
"name": "@push.rocks/logcontext", "name": "@push.rocks/logcontext",
"version": "2.0.0", "version": "2.0.0",
"description": "enrich logs with context", "description": "A module to enrich logs with context, featuring async log contexts and scope management.",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts", "typings": "dist_ts/index.d.ts",
"author": "Lossless GmbH", "author": "Lossless GmbH",
@ -42,5 +42,13 @@
"npmextra.json", "npmextra.json",
"readme.md" "readme.md"
], ],
"type": "module" "type": "module",
"keywords": [
"logging",
"context enrichment",
"async log contexts",
"scope management",
"typescript",
"nodejs"
]
} }

1
readme.hints.md Normal file
View File

@ -0,0 +1 @@

126
readme.md
View File

@ -1,82 +1,92 @@
# @pushrocks/logcontext # @push.rocks/logcontext
enrich logs with context enrich logs with context
## Availabililty and Links ## Install
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/logcontext) To incorporate @push.rocks/logcontext into your project, you will need Node.js and npm (Node Package Manager) installed. Once you have those prerequisites, you can install @push.rocks/logcontext by running the following command in your project's root directory:
* [gitlab.com (source)](https://gitlab.com/pushrocks/logcontext)
* [github.com (source mirror)](https://github.com/pushrocks/logcontext)
* [docs (typedoc)](https://pushrocks.gitlab.io/logcontext/)
## Status for master ```shell
npm install @push.rocks/logcontext --save
```
Status Category | Status Badge This command will download and install @push.rocks/logcontext and its dependencies into your project's `node_modules` folder and save it as a dependency in your project's `package.json` file.
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/logcontext/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/logcontext/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/logcontext)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/logcontext)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/logcontext)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/logcontext)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/logcontext)](https://lossless.cloud)
## Usage ## Usage
Use TypeScript for best in class instellisense. @push.rocks/logcontext is a TypeScript-focused module designed to enrich logging operations with contextual information, making it easier to trace logs through asynchronous operations in Node.js applications. It leverages modern JavaScript features such as async/await and provides a structured way to append and manage log-specific context.
the logconext module exposes an easy to use syntax for nodejs style async logcontexts. ### Getting Started
First, ensure that you import the `Logger` class from @push.rocks/logcontext at the beginning of your TypeScript file:
```typescript ```typescript
let testLogger = new logcontext.Logger('testNamespace'); import { Logger } from "@push.rocks/logcontext";
testLogger.scope(async () => {
testLogger.addData('id1', {
someData: 'someValue',
});
testLogger.log('hi');
testLogger.error(new Error('custom error message'));
setTimeout(() => {
outsideFunction(); // log scope will travel through callbacks and promises
}, 2000);
});
let outsideFunction = () => {
// Note:
// the below testLogger reference will have different contexts
// depending from which scope "outsideFunction" was called".
testLogger.log('some message');
};
``` ```
## class Logger ### Creating a Logger Instance
To start logging with context, you'll first need to create an instance of a logger. Optionally, you can provide a namespace string during instantiation to differentiate logs from different parts of your application.
```typescript ```typescript
import { Logger } from 'logcontext'; const appLogger = new Logger("appNamespace");
```
// instantiate new Logger If no namespace is provided, a unique ID will be generated to serve as the namespace.
// argument optional, if left empty auto generated shortid will be used
let myLogger = new Logger('myNamespace');
// create a scope ### Adding Context and Logging
myLogger.scope(async () => {
// everything that is appended to the call stack from inside here will have all appended context data available
// add some scoped context information One of the core features of @push.rocks/logcontext is the ability to associate contextual data with logs. This is very useful in asynchronous operations where tracing the flow of execution through different contexts is necessary.
myLogger.addData('customerId', '12345678');
// will log something with priviously appended context of this scope in place #### Scoping Contexts
myLoger.log('awesomeText');
To scope a context, use the `scope` function of the Logger instance. This function takes an async function as an argument, and any logs emitted within this function will include the provided scoped context.
```typescript
appLogger.scope(async () => {
appLogger.addData("userId", 123);
appLogger.log("User authenticated");
// Further async operations where logs should include { userId: 123 }
}); });
``` ```
## Contribution #### Asynchronous Context Propagation
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :) The context you define will propagate through asynchronous calls, ensuring that logs emitted after asynchronous operations still contain the context that was active when the operation started.
For further information read the linked docs at the top of this readme. #### Available Logging Methods
## Legal @push.rocks/logcontext exposes several logging methods, including `log`, `error`, `warn`, `info`, and `debug`. These methods are intended to mirror the conventional logging levels, making it easier to integrate into existing logging strategies.
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy) ```typescript
appLogger.log("A standard log message.");
appLogger.error("An error message.");
appLogger.warn("A warning message.");
appLogger.info("An informational message.");
appLogger.debug("A debug message.");
```
### Integrating with Third-Party Loggers
While @push.rocks/logcontext works well on its own for adding context to logs, it also supports integration with third-party logging solutions. You can associate a third-party logger using the `addThirdPartyLogger` method. This allows you to leverage the structured logging features of @push.rocks/logcontext while utilizing the logging infrastructure provided by another package.
### Conclusion
@push.rocks/logcontext offers a powerful and flexible solution for enriched logging in Node.js applications. By enabling contextual logging and integrating seamlessly with asynchronous operations, it facilitates better traceability and debugging of applications. Whether used standalone or alongside other logging libraries, @push.rocks/logcontext helps maintain clear and useful logs in complex applications.
## License and Legal Information
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
### Trademarks
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
### Company Information
Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.