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

argon-logger

v1.0.2

Published

A simple console logging utility

Downloads

777

Readme

Argon logger

Argon Logger is a powerful tool built to enhance and surpass the traditional console.log(...) functionality. It provides comprehensive control over the output of your logs, allowing you to customize their behavior according to your specific needs.

With Argon Logger, you can seamlessly replace console.log(...) with a more flexible and versatile logging solution. You gain the ability to determine exactly how your logs should be handled, giving you greater control over their visibility and destination.

In production environments, security is paramount. Argon Logger offers the option to suppress logs entirely, ensuring that sensitive information remains hidden from prying eyes. You can rest assured that your logs won't inadvertently expose critical data.

Additionally, Argon Logger allows you to redirect logs to alternative destinations beyond the default console. This flexibility enables you to capture logs in various contexts, such as storing them in a file, sending them to a remote server, or integrating them with a dedicated logging service. The choice is yours, and Argon Logger empowers you to tailor the log output to suit your specific requirements.

By leveraging Argon Logger, you can elevate your logging capabilities, enhance security, and achieve greater flexibility in handling log messages. Say goodbye to the limitations of console.log(...) and unlock a new level of control and customization with Argon Logger.

Install

npm i argon-logger

Usage

Argon Logger provides a familiar interface that closely resembles the widely used console object. You can seamlessly integrate it into your codebase and start leveraging its enhanced logging capabilities. Here's an example showcasing how to use Argon Logger:

import { logger } from "argon-logger";

logger.log("Hello"); // Output: Hello
logger.warn("This is a warning"); // Output: This is a warning
logger.error("This is an error"); // Output: This is an error
logger.debug("This is a debug message"); // Output: This is a debug message
logger.info("This is an info message"); // Output: This is an info message

As you can see, using Argon Logger is similar to utilizing regular console methods. You can call logger.log(...), logger.warn(...), logger.error(...), logger.debug(...), and logger.info(...) to log messages of different severity levels.

However, what sets Argon Logger apart is its intelligent filtering and customization capabilities. By default, it offers a concise set of API methods to ensure a compact library size. It also limits log visibility to the localhost environment, which enhances security by preventing logs from being exposed in production environments.

Moreover, Argon Logger provides the flexibility to extend its API and modify restriction levels. Consider the following example:

import { autowire, Logger } from "argon-logger";

class MyLogger extends Logger {
  constructor(config) {
    super(config);
  }

  @autowire() // Automatically wires "console" method if the API supports it
  time() {}

  @autowire()
  timeEnd() {}

  customLogMethod(...args) {
    this.api.log(...args);
  }
}

const logger = new MyLogger({
  api: console, // The default api is "console"
  disable: location.hostname !== "localhost",
});

logger.time("Timer");
// ...
logger.timeEnd("Timer");
logger.customLogMethod("Custom method");

In this example, a custom logger class, MyLogger, extends the base Logger class from Argon Logger. It introduces additional methods such as time(), timeEnd(), and customLogMethod(). The @autowire() decorator automatically wires the corresponding methods from the API if supported. By customizing the logger, you can tailor it to your specific needs.

With Argon Logger, you gain not only the simplicity and familiarity of console-like methods but also the ability to fine-tune and extend its functionality to suit your requirements. Empower your logging experience with Argon Logger and unlock its powerful customization options.

Contributing

We welcome contributions from the community to enhance the plugin's functionality and address any issues. If you have any feedback, bug reports, or feature requests, please don't hesitate to open an issue or submit a pull request on GitHub.