npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

logsilo

v1.0.1

Published

A lightweight logging utility for sending logs to a configured endpoint.

Downloads

165

Readme

LogSilo

A lightweight logging utility for sending logs to a configured endpoint.

Installation

Use the package manager npm to install Silo.

npm install logsilo

Usage

1. Importing and Initializing Silo

To start using Silo, first import it and create an instance with your specific configuration.

import silo, { Silo, SiloLog } from 'logsilo';

// Create an instance of Silo with your configuration
const siloInstance: Silo = silo.create({
  apiKey: 'Your Silo Backend Api Key' // The api key of the backend
  apiUrl: 'https://your-backend-api-url', // The backend endpoint for sending logs
  application: 'Your App Name',           // The name of your application
});

2. Creating a Log Entry

Once you have an instance, create individual log entries using the SiloLog class. Each log entry allows for customizable properties.

const siloLog: SiloLog = new SiloLog({
  shortDescription: 'This is a 404 test log', // Required, brief description of the log
  detailedDescription: 'This is the longer description of the 404 test log which occurred...', // Optional, detailed description
  service: 'Your Service Which Produced The Log', // Optional, name of the service responsible
  level: 2,                                      // Optional, severity level of the log (e.g., 1 = Info, 2 = Warning, 3 = Error)
  user: 'John Doe',                              // Optional, user associated with the log
  path: '/some-super-test-route',                // Optional, route or path related to the log event
  statusCode: 404,                               // Optional, HTTP status code (if applicable)
  timestamp: new Date()                          // Optional default is new Date()
});

3. Using LogSilo

With your log entry created, you can use the following methods with your siloInstance.

// Display the log in the console
siloInstance.console(siloLog);

// Send the log to the backend API specified in the instance's configuration
siloInstance.send(siloLog);

// Display the current configuration of the instance in the console
siloInstance.showConfig();

// Show the Silo logo in the console
siloInstance.showSiloArt();

Example

import silo, { Silo, SiloLog } from 'logsilo';

// Initialize an instance
const siloInstance: Silo = silo.create({
  apiKey: 'Your Silo Backend Api Key',
  apiUrl: 'https://your-backend-api-url',
  application: 'Example App',
});

// Create a log entry
const exampleLog: SiloLog = new SiloLog({
  shortDescription: 'Example log entry',
  detailedDescription: 'Detailed information about this log entry...',
  service: 'Example Service',
  level: 1,
  user: 'Alice Doe',
  path: '/example-path',
  statusCode: 400,
});

// Log to console and send to API
siloInstance.console(exampleLog);
try {
  const response = await siloInstance.send(exampleLog);
} catch (error) {
  console.error(error);
}

// Display config and show the logo
siloInstance.showConfig();
siloInstance.showSiloArt();

Api Reference

create(config): Creates and returns a new Silo instance.
apiUrl (string): The endpoint to send logs to.
application (string): The application name.
console(log): Logs the entry to the console.
send(log): Sends the log to the specified API.
showConfig(): Displays the current instance configuration in the console.
showSiloArt(): Shows the Silo logo art in the console.

License

ISC