0.0.2 • Published 7 months ago

log-viewer-sdk-node v0.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
7 months ago

Log Viewer SDK for Node.js

The Log Viewer SDK for Node.js allows you to capture and log events from your Node.js application to the Log Viewer platform so you can monitor and analyze your application's performance and behavior from the Log Viewer UI. Its built with a worker-based architecture, ensuring the main thread remains unaffected. Check out the Log Viewer platform for more information.

Features

  • Non-blocking logging: Uses worker threads under the hood.
  • Flexible: Fits most logging needs.
  • Environment-aware: Logs events with environment context (production, staging, development).
  • Scalable: Handles high-frequency logging efficiently.
  • TypeScript ready: Fully typed for a better developer experience.
  • CommonJS and ESM: Supports both CommonJS and ESM module systems.

Installation

Install the package via npm:

npm install log-viewer-sdk-node

Event Object Structure

The event object passed to the logger should follow this structure:

KeyTypeRequiredDescription
levelstringYesSeverity level; "critical" , "error" , "warn" , "info"
log_typestringYesType; "api" , "database" , "internal" , "webhook"
messagestringNoDescriptive message for the log.
stackstringNoStack trace details.
request_idstringNoIdentifier for the request.
ip_addressstringNoIP address of the client.
request_payloadstringNoSerialized payload of the request.
function_namestringNoName of the function where the log occurred.
status_codenumberNoHTTP status code.
endpointstringNoAPI endpoint or resource being accessed.

Usage

//typescript

import { createEventLogger } from "log-viewer-sdk-node";

const logger = createEventLogger({
  serviceUrl: "https://api.logviewer.io/your-service-key", 
  environment: "staging", // or production or development
});

logger({
  level: "info",
  log_type: "internal",
  message: "This is a test message",
});
//commonjs

const { createEventLogger } = require("log-viewer-sdk-node");