1.7.4 • Published 8 months ago

@goldenhippo/gh-service-utils v1.7.4

Weekly downloads
-
License
UNLICENSED
Repository
github
Last release
8 months ago

Golden Hippo Service Utilities

A collection of general utilities designed to streamline logging, event tracking, and other common operations across multiple services at Golden Hippo. This package is intended to be flexible, reusable, and easily integrated into various applications.

Features

  • General Logger: A simple logger for outputting unstructured text messages.
  • Event Logger: A structured logger for tracking events with customizable options like brand, action, status, request ID, etc.

Installation

npm install @goldenhippo/gh-service-utils

Usage

import { HippoLogger } from '@goldenhippo/gh-service-utils'

const log = new HippoLogger({
  filePath = __filename, 
  brand = 'Gundry MD', 
  level = 'info',
  requestId = 'ABC123'
})

// Unstructured Log
log.note('This is a general log message.'); // Logs: This is a general log message.

// Structured Log
log.event({
  action: 'Sync Funnel Event', 
  status: 'In progress', 
  details: 'Retrieved 100 logs'
}) // Logs: [someFileName.ts] [ABC123] [master] - Brand: Gundry MD | Action: Sync Funnel Event | Status: In progress | Details: Retrieved 100 logs

Note Log

The note function creates a basic logger for printing messages to the console.

Event Log

The event method creates a structured logger with options to track events like brand, action, status, and more.

HippoLogger Options

Description: Creates a structured event logger.

OptionTypeDefaultDescription
filePathstring'N/A'Path to the file where the logger is used (for namespace).
brandstring'N/A'The brand for which the log is being generated.
actionstring'N/A'Specific action being logged (e.g., "Retrieving orders").
statusstring'N/A'Status of the action (e.g., "In progress").
detailsstring'N/A'Additional details about the log entry.
requestIdstring'N/A'Custom request ID or auto-generated by cls-rtracer.
levelstring'info'Log level (info, error, etc.).
1.2.0

1 year ago

1.7.3

10 months ago

1.7.2

10 months ago

1.7.1

1 year ago

1.5.3

1 year ago

1.7.0

1 year ago

1.5.2

1 year ago

1.6.0

1 year ago

1.5.1

1 year ago

1.3.3

1 year ago

1.5.0

1 year ago

1.3.2

1 year ago

1.4.0

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.7.4

8 months ago

1.1.0

1 year ago

1.0.0

1 year ago