From fc0f6b2ae3b4cc5d8c1c1edb7eb68c4f29b74004 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Sun, 14 Apr 2024 17:51:13 +0200 Subject: [PATCH] update tsconfig --- npmextra.json | 17 ++++++- package.json | 14 +++++- readme.hints.md | 1 + readme.md | 131 ++++++++++++++++++++++++++++++++++++++---------- 4 files changed, 133 insertions(+), 30 deletions(-) create mode 100644 readme.hints.md diff --git a/npmextra.json b/npmextra.json index a65196f..25cfbcd 100644 --- a/npmextra.json +++ b/npmextra.json @@ -8,14 +8,27 @@ "shortDescription": "a smartlog destination for transparently writing to a file", "npmPackagename": "@push.rocks/smartlog-destination-file", "license": "MIT", - "projectDomain": "push.rocks" + "projectDomain": "push.rocks", + "description": "A module for creating a log destination that writes to a file with support for smartlog interfaces.", + "keywords": [ + "logging", + "smartlog", + "file-logging", + "typescript", + "node.js", + "filesystem", + "log management", + "development tool", + "log destination", + "log file" + ] } }, "npmci": { "npmGlobalTools": [], "npmAccessLevel": "public" }, - "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" } } \ No newline at end of file diff --git a/package.json b/package.json index 6b1b6d7..936634b 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@push.rocks/smartlog-destination-file", "version": "1.0.7", "private": false, - "description": "a smartlog destination for transparently writing to a file", + "description": "A module for creating a log destination that writes to a file with support for smartlog interfaces.", "main": "dist_ts/index.js", "typings": "dist_ts/index.d.ts", "author": "Lossless GmbH", @@ -36,5 +36,17 @@ "cli.js", "npmextra.json", "readme.md" + ], + "keywords": [ + "logging", + "smartlog", + "file-logging", + "typescript", + "node.js", + "filesystem", + "log management", + "development tool", + "log destination", + "log file" ] } \ No newline at end of file diff --git a/readme.hints.md b/readme.hints.md new file mode 100644 index 0000000..0519ecb --- /dev/null +++ b/readme.hints.md @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/readme.md b/readme.md index 71b6294..601335b 100644 --- a/readme.md +++ b/readme.md @@ -1,39 +1,116 @@ -# @pushrocks/smartfile-destination-file +# @push.rocks/smartlog-destination-file a smartlog destination for transparently writing to a file -## Availabililty and Links -* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartfile-destination-file) -* [gitlab.com (source)](https://gitlab.com/pushrocks/smartfile-destination-file) -* [github.com (source mirror)](https://github.com/pushrocks/smartfile-destination-file) -* [docs (typedoc)](https://pushrocks.gitlab.io/smartfile-destination-file/) +## Install +To install `@push.rocks/smartlog-destination-file`, use the following command with npm: -## Status for master +```bash +npm install @push.rocks/smartlog-destination-file --save +``` -Status Category | Status Badge --- | -- -GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartfile-destination-file/badges/master/pipeline.svg)](https://lossless.cloud) -GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartfile-destination-file/badges/master/coverage.svg)](https://lossless.cloud) -npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smartfile-destination-file)](https://lossless.cloud) -Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartfile-destination-file)](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/smartfile-destination-file)](https://lossless.cloud) -PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartfile-destination-file)](https://lossless.cloud) -BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartfile-destination-file)](https://lossless.cloud) -Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud) +This will add the package to your project's dependencies. ## Usage -Use TypeScript for best in class intellisense +To use `@push.rocks/smartlog-destination-file` in your project, you need to import and instantiate it with the path to the log file you wish to write to. This path should be absolute to ensure correct file writing regardless of the current working directory of your application. -## Contribution +First, ensure that your TypeScript configuration supports ECMAScript modules (ESM) syntax. Then, follow the steps below for setup and usage examples. -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). :) +### Basic Setup -For further information read the linked docs at the top of this readme. +Here is how to instantiate `SmartlogDestinationFile` and use it to log messages: -> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) -| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy) +```typescript +// Import dependencies +import { SmartlogDestinationFile } from '@push.rocks/smartlog-destination-file'; +import path from 'path'; -[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com) +// Define the absolute path to the log file +const logFilePath = path.resolve(__dirname, 'mylogs.log'); + +// Create an instance of SmartlogDestinationFile +const myLogDestination = new SmartlogDestinationFile(logFilePath); + +// Example log message +const logMessage = { + context: 'ExampleApp', + correlation: { + id: 'unique-correlation-id', + type: 'example' + }, + level: 'info', + message: 'This is an example log message', + timestamp: Date.now(), + type: 'log', + data: null +}; + +// Log the message +myLogDestination.handleLog(logMessage).then(() => { + console.log('Log message was successfully written to file'); +}).catch((error) => { + console.error('Error writing log message to file:', error); +}); +``` + +The `handleLog` method is asynchronous and returns a Promise. It's important to handle both successful and unsuccessful attempts to log messages. + +### Advanced Usage + +`@push.rocks/smartlog-destination-file` integrates smoothly with `@pushrocks/smartlog` to provide a structured logging solution. You can easily set it as a destination for your smartlog instance. Here's how to do it: + +1. Install `@pushrocks/smartlog` along with `@push.rocks/smartlog-destination-file`: + + ```bash + npm install @push.rocks/smartlog @push.rocks/smartlog-destination-file --save + ``` + +2. Set up `SmartlogDestinationFile` as a destination in `Smartlog`: + + ```typescript + import { Smartlog } from '@pushrocks/smartlog'; + import { SmartlogDestinationFile } from '@push.rocks/smartlog-destination-file'; + import path from 'path'; + + const logFilePath = path.resolve(__dirname, 'myStructuredLogs.log'); + const fileDestination = new SmartlogDestinationFile(logFilePath); + + // Initialize Smartlog + const myLogger = new Smartlog({ + minLevel: 'info', + destinations: [ + fileDestination // Your instance of SmartlogDestinationFile + ] + }); + + // Use Smartlog to log a message + myLogger.log({ + level: 'info', + message: 'Structured log message with Smartlog and SmartlogDestinationFile', + type: 'business', + context: 'exampleContext' + }); + ``` + +This setup gives you the power of structured logging with the convenience of `@pushrocks/smartlog`'s log management capabilities, directing all logs to a file specified in `SmartlogDestinationFile`. + +Remember, `@push.rocks/smartlog-destination-file` is versatile and can be adapted to various logging strategies, playing a crucial role in the observability and debugging capabilities of your application. By leveraging its simplicity and integration with `@pushrocks/smartlog`, you can achieve an effective logging solution with minimal setup. + +## 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.