splunk-hec-logger
v1.0.4
Published
send logs to splunk cloud hec
Readme
📘 Splunk Cloud HTTP Event Collector Service
🛠️ Overview
The Splunk Logging Service is a library designed to provide centralized logging functionality for frontend applications. It includes a singleton LoggingService class and supports custom logger implementations via the GenericLogger interface.
✨ Features
- 🏷️ Singleton Logging Service: Centralized logging with a single active instance.
- 🔧 Custom Logger Support: Easily integrate your own logger implementations via the
GenericLoggerinterface.
👉 If you want to add support for other frontend frameworks, feel free to create a pull request! - 🚀 Simple Initialization: Start logging with minimal setup.
📦 Installation
Install the package using npm:
npm install splunk-hec-logger🚀 Usage
Initializing the Logging Service
To initialize the logging service, provide a logger that implements the GenericLogger interface (f.e. Ui5LoggerAdapter):
import LoggingService, { Ui5LoggerAdapter } from "splunk-hec-logger";
const logger = new Ui5LoggerAdapter(...);
LoggingService.initService(logger);
LoggingService.getInstance().start();📖 API
LoggingService
initService(logger: GenericLogger): voidInitializes the logging service with the provided logger. Ensures only one instance of the service is active.getInstance(): LoggingServiceReturns the Instance of the LoggingService. This public function can only be called afterinitService(...)function, otherwise error is thrown.
Ui5LoggerAdapter
A pre-built logger adapter tailored for UI5 applications with version 1.120.
🛠️ Interfaces
GenericLogger
The GenericLogger interface defines the contract for custom loggers.
📜 License
This project is licensed under the MIT License.
