---
title: "@push.rocks/smartlog-destination-receiver"
---
# @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:

```bash
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:

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

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

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

```typescript
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 applicationâs needs and compliance requirements.

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