A package providing a destination handler for smartlog logging packages
Go to file
2024-05-29 14:14:20 +02:00
.vscode fix(core): update 2022-06-26 09:27:01 +02:00
test fix(core): update 2024-05-18 01:34:54 +02:00
ts fix(core): update 2024-05-18 01:34:54 +02:00
.gitignore fix(core): update 2020-06-05 16:10:52 +00:00
license fix(core): initial 2018-11-11 14:29:26 +01:00
npmextra.json update tsconfig 2024-04-14 17:52:36 +02:00
package-lock.json 2.0.6 2024-05-18 01:34:54 +02:00
package.json update description 2024-05-29 14:14:20 +02:00
pnpm-lock.yaml fix(core): update 2024-05-18 01:32:05 +02:00
qenv.yml fix(core): update 2020-06-05 16:25:36 +00:00
readme.hints.md update tsconfig 2024-04-14 17:52:36 +02:00
readme.md update tsconfig 2024-04-14 17:52:36 +02:00
tsconfig.json update npmextra.json: githost 2024-04-01 21:36:12 +02:00

@push.rocks/smartlog-destination-receiver

a smartlog destination for smartlog-receiver

Install

To include @push.rocks/smartlog-destination-receiver in your project, add it as a dependency by running:

npm install @push.rocks/smartlog-destination-receiver --save

This command will download and add the package to your project's package.json file.

Usage

This module offers a modern TypeScript approach to interact with logging destinations, particularly designed for use with smartlog-receiver. Below are outlined scenarios to effectively utilize the module, showcasing its functionalities.

Prerequisites

Ensure that you have TypeScript and the necessary types included in your project. Include the module in your TypeScript file with ESM syntax:

import { SmartlogDestinationReceiver } from '@push.rocks/smartlog-destination-receiver';

Basic Setup

To get started, you need to instantiate SmartlogDestinationReceiver with the required configuration. This configuration primarily includes the passphrase for authentication and the receiverEndpoint where the logs will be sent.

import { SmartlogDestinationReceiver } from '@push.rocks/smartlog-destination-receiver';

// Initialize with options
const logReceiver = new SmartlogDestinationReceiver({
  passphrase: 'your_passphrase', // Provide the passphrase for authentication
  receiverEndpoint: 'https://your.log.receiver.endpoint' // Endpoint to send logs to
});

Sending Logs

With SmartlogDestinationReceiver, sending logs is crafted to be straightforward. Below is an example demonstrating how to send a basic log message.

import { SmartlogDestinationReceiver } from '@push.rocks/smartlog-destination-receiver';

// Instantiate the log receiver
const logReceiver = new SmartlogDestinationReceiver({
  passphrase: 'your_passphrase', // Authentication
  receiverEndpoint: 'https://your.log.receiver.endpoint'
});

// Prepare a log message
const logMessage = {
  timestamp: Date.now(),
  context: {
    company: 'Your Company',
    companyunit: 'Your Unit',
    containerName: 'your-service-name',
    environment: 'production',
    runtime: 'node',
    zone: 'your-zone'
  },
  type: 'log',
  level: 'info',
  correlation: {
    id: 'unique-correlation-id',
    type: 'SpecificCorrelationType'
  },
  message: 'This is a test log message'
};

// Send the log message
await logReceiver.handleLog(logMessage);

This setup will securely send your log message to the configured endpoint. Ensure that the endpoint is prepared to receive and process messages in the structure provided.

Error Handling

It's practical to implement error handling to manage any issues that might arise during the log transmission process. SmartlogDestinationReceiver internally catches errors related to the sending process, but you can also wrap calls in try-catch blocks for more comprehensive control.

try {
  await logReceiver.handleLog(logMessage);
} catch (error) {
  console.error('Failed to send log:', error);
}

This approach lets you handle any unexpected errors gracefully, ensuring your application's stability.

Advanced Usage

The SmartlogDestinationReceiver can be easily integrated into larger logging systems or services that handle various log destinations. Its simple, promise-based API allows for integration with async/await syntax, facilitating complex logging operations and workflows.

Remember, this module is designed to work seamlessly within the smartlog ecosystem, enabling highly configurable, scalable, and secure logging solutions across microservices, applications, and infrastructure.

Conclusion

The @push.rocks/smartlog-destination-receiver module provides a robust and flexible way to send logs to a designated receiver. By seamlessly integrating with TypeScript projects and offering straightforward configuration and usage patterns, it empowers developers to maintain high-quality logging practices with minimal overhead.

For comprehensive details on further configurations and advanced features, refer to the module documentation and API references. Always aim to understand the full capabilities of the logging solutions you implement, ensuring they align with your applications needs and compliance requirements.

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 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.