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

logitt

v1.0.6

Published

Logitt is a robust NodeJS library designed for efficient log management. It allows you to save logs seamlessly and provides an intuitive interface to explore and analyze them, enhancing your application's monitoring and debugging capabilities.

Downloads

17

Readme

Logitt

Logitt is a powerful NodeJS library for efficient log management. It seamlessly saves logs and offers an intuitive interface for exploring and analyzing them, enhancing your application's monitoring and debugging capabilities.

Logs Viewer Preview

Why Choose Logitt?

  • Easy to Integrate: Simple to add to your projects.
  • Lightweight: Minimal package size for optimal performance.
  • User-Friendly Interface: Includes an intuitive UI for viewing logs.
  • Framework-Independent: Works with any NodeJS application

Install

Using NPM:

$ npm install logitt

Using YARN:

$ yarn add logitt

Usage

Logitt provides a straightforward logger and an easy-to-use interface for viewing logs. Here's how to get started:

  • Configuration: Set up your environment variables before using the library.

  • Development Mode: By default, Logitt operates in "development" mode, displaying all logs in the console using Consola

  • Production Mode: To save logs to files (stored in the "/logs" folder), update your environment variables as follows:

NODE_ENV="production"

1. Instantiate

Logitt employs the Singleton design pattern. You can configure the logger by changing the URL of the UI Explorer or by enabling/disabling tracing.

const { Logitt } = require("logitt");

// Default configuration options
const options = {
  // Enable tracing to identify the source of the log
  trace: true,
  // Set the URL path for the UI Explorer
  route: "/logs",
};

// Create a new instance with custom options, if not already created
const loggy = Logitt.getLogger(options);

// Create a new instance with default options
const loggy = Logitt.getLogger();

2. Logging

Logitt provides 4 logging levels: SUCCESS, DEBUG, WARNING, and ERROR.

  • SUCCESS: Always logs to the console, regardless of the environment.
  • DEBUG: For detailed debugging information.
  • WARNING: For warning messages.
  • ERROR: For error messages.

Here's how to use them:

loggy.warn("Warning occured here");
loggy.error("Error occured here");
loggy.debug("Debug occured here");
loggy.success("Success occured here");

// You can also log directly using the singleton instance
// Logitt.getLogger().warn("Warning occured here")

To include additional context or metadata with your logs:

loggy.error("Unable to create a new user", {
  name: "John Doe",
  email: "[email protected]",
  phone: null,
});

3. UI Explorer

To access the UI Explorer and view your logs, you need to set your credentials as environment variables:

LOGITT_USERNAME=your_username
LOGITT_PASSWORD=your_password

3.1. No Framework

const { Logitt } = require("logitt");
const http = require("http");

const loggy = Logitt.getLogger();

http.createServer(loggy.render).listen(PORT, () => {
  consola.start(`Server is running on port ${PORT} ...\n`);
});

3.2. ExpressJS

const { Logitt } = require("logitt");
const express = require("express");

const app = express();

app.get("/logs", Logitt.getLogger().render);

// Custom URL
app.get("/my-logs", Logitt.getLogger({ route: "/my-logs" }).render);

3.3. NestJS

import { Controller, Get, Req, Res } from "@nestjs/common";
import { Request, Response } from "express";
import { Logitt } from "logitt";

@Controller()
export class AppController {
  constructor() {}

  @Get("/logs")
  getLogs(@Req() req: Request, @Res() res: Response) {
    let logitt = Logitt.getLogger();
    logitt.render(req, res);
  }

  // Custom URL
  @Get("/my-logs")
  getLogs(@Req() req: Request, @Res() res: Response) {
    let logitt = Logitt.getLogger({ route: "/my-logs" });
    logitt.render(req, res);
  }
}

ISC License

Copyright 2024

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.