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

@sevapp/luminous

v0.1.6

Published

Extremely configurable logger for Deno and Node.js

Downloads

1

Readme

luminous

deno.land/x/luminous popularity npm version npm downloads npm license

DENO RU COMMUNITY

👋 👋 ATTENTION!

This package is under development and will be frequently updated. The author would appreciate any help, advice, and pull requests! Thank you for your understanding 😊

Luminous is a extremely configurable logger for Deno written in TypeScript. It provides a simple and flexible way to log events and messages in Deno applications with various levels of severity. With Luminous, developers can configure the logger to meet their specific needs and customize the logging format to suit their preferences.

Usage

import luminous from 'https://deno.land/x/[email protected]/mod.ts';

const log = new luminous.Logger();
log.trc`Hello, World!`;

Examples

deno task exmaple:simple
  • inheritance of options when creating new loggers: hierarchy.ts, run:
deno task exmaple:hierarchy

Contents

Levels

Luminous provides eight different logging levels that enable developers to log events and messages with different levels of severity. Each level is designed to serve a specific purpose and can help developers troubleshoot issues and debug complex problems. 0 TRACE:

log.trc`This is TRACE log message`;
// 01:58:35 [TRC] default: This is TRACE log message

The TRACE level is the lowest level of severity in Luminous. This level is used to log the most detailed information about an application's execution, such as method calls, function parameters, and variable values. The TRACE level is useful for debugging complex issues and identifying the root cause of a problem.

1 DEBUG:

log.dbg`This is DEBUG log message`;
// 01:58:35 [DBG] default: This is DEBUG log message

The DEBUG level is used to log debugging information that is useful for developers during application development. This level can include information about application flow, execution paths, and other relevant details that can help developers identify and fix bugs.

2 VERBOSE:

log.vrb`This is VERBOSE log message`;
// 01:58:35 [VRB] default: This is VERBOSE log message

The VERBOSE level is used to log detailed information that is not critical to the application's operation but can be useful for developers during debugging. This level includes information about application state, network activity, and other detailed events.

3 INFO:

log.inf`This is INFO log message`;
// 01:58:35 [INF] default: This is INFO log message

The INFO level is used to log information about the application's operation. This level includes messages that indicate when the application starts or stops, when it performs significant operations, or when it encounters events that may be of interest to developers or system administrators.

4 USER:

log.usr`This is USER log message`;
// 01:58:35 [USR] default: This is USER log message

The USER level is used to log events that are relevant to end-users, such as login attempts, user actions, and other user-related events. This level is useful for tracking user behavior and identifying usability issues.

5 WARN:

log.wrn`This is WARN log message`;
// 01:58:35 [WRN] default: This is WARN log message

The WARN level is used to log warnings about potential issues that may affect the application's operation. This level includes messages about deprecated APIs, invalid configuration settings, or other issues that may cause unexpected behavior.

6 ERROR:

log.err`This is ERROR log message`;
// 01:58:35 [ERR] default: This is ERROR log message

The ERROR level is used to log errors that occur during application execution but are recoverable. This level includes messages about exceptions, timeouts, or other errors that may require attention but do not necessarily require the application to stop.

7 FATAL:

log.ftl`This is FATAL log message`;
// 01:58:35 [FTL] default: This is FATAL log message

The FATAL level is used to log critical errors that require immediate attention and may cause the application to stop. This level includes messages about unrecoverable errors, such as out-of-memory errors, disk failures, or other catastrophic events.

Logger Options

LoggerOptions in Luminous are a set of configurable settings that enable developers to customize the behavior and functionality of the logger to meet their specific needs. The OptionsBuilder class in Luminous is a utility class that provides a fluent API for building and configuring logger options. It allows developers to create and customize LoggerOptions objects in a flexible and intuitive way, by providing a set of methods for setting various options. For example:

const loggerOptions = new luminous.OptionsBuilder()
  .setName('Main')
  .build();

const logger = new luminous.Logger(loggerOptions);
logger.inf`Hello, World!`;

Transports

The AbstractTransport is the base class for all transports in Luminous. A transport is responsible for sending formatted log messages to their final destination, which could be the console, a file, a database, or any other endpoint. At the moment, Luminous has a TerminalTransport. For example:

// Create a new instance of TerminalTransport to send logs to the terminal.
const transport = new luminous.transports.TermianlTransport(),

// Create a new OptionsBuilder instance to configure the logger options.
const loggerOptions = new luminous.OptionsBuilder()
  .setName('Main') // Set the name of the logger to 'Main'.
  .addTransport(
    new luminous.formatters.TextFormatter(),
    transport,
  ) // Add the TextFormatter and TerminalTransport to the logger.
  .build(); // Build the final logger options object.

// Create a new logger instance with the configured options.
const logger = new luminous.Logger(loggerOptions);

// Log an information message.
logger.inf(`Hello, World!`);
// 01:58:35 [INF] Main: Hello, World!

Formatters

In Luminous, a AbstractFormatter is a class that is responsible for formatting log messages into a human-readable string format. The IDataForFormatting interface defines the data that is passed to the formatter, which includes the name of the logger, the severity level of the log message, the message itself, and any additional metadata that may be attached to the message. Currently, Luminous has two basic forrmaters: TextFormatter and JsonFormatter. For example:

// Create a new TextFormatter instance that formats log messages as text with metadata and a custom timestamp pattern.
const textFormatter = new luminous.formatters.TextFormatter({
  showMetadata: true,
  timestampPattern: 'yyyy-MM-dd HH:mm:ss',
});

// Create a new OptionsBuilder instance to configure the logger options.
const loggerOptions = new luminous.OptionsBuilder()
  .setName('Main') // Set the name of the logger to 'Main'.
  .addTransport(
    textFormatter,
    new luminous.transports.TerminalTransport(),
  ) // Add the TextFormatter and TerminalTransport to the logger.
  .build(); // Build the final logger options object.

// Create a new logger instance with the configured options.
const logger = new luminous.Logger(loggerOptions);

// Log an information message with metadata.
logger.inf(`Hello, World!`, { meta0: '0', meta1: '1' });
// 2023-02-26 01:58:35 [INF] Main: Hello, World! {
//  meta0: "0"
//  mrta1: "1"
// }

DONATE

🫶 You can support me and my work in the following ways: TON: EQBiaSPuG33CuKXHClwsVvA-SazmLmtiTfXV7dQnqJdIlGgI USDT (TRC 20) (TRC20): TGPWzEiQjMYHjZx4fb3SDSumiSXdmjE4ZR BTC: bc1qq37svf4h8sg5qjsv99n9jf3r45dtd5yf5mdpc5 ETH: 0xAdc58F26cA3dCc01256cF1BeF6221f4bcaa3c660 SOL: BckFFoxZw36ABbNS8Fc66LCdzJhu4ZwQANRdq49XmqKw

LICENCE

LGPL-2.1