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

@gakuto1112/nodejs-logger

v1.0.0

Published

Logger module that formats stdout to make it easy to see

Downloads

1

Readme

NodeJSLogger

This module formats log outputs to make them easy to see!

It adds date and time when the log output, file name that calls log functions, and log type.

[2023/9/22 2:54:08] [PluginManager.js] [INFO]: Loading plugins...
[2023/9/22 2:54:08] [ConfigManager.js] [INFO]: Started reading config file.
[2023/9/22 2:54:08] [ConfigManager.js] [INFO]: Finished reading config file.
[2023/9/22 2:54:08] [ConfigManager.js] [INFO]: Checking new config addition...
[2023/9/22 2:54:08] [ConfigManager.js] [INFO]: New config values detected. Updating config file...
[2023/9/22 2:54:08] [ConfigManager.js] [INFO]: Finished Updating config file.
[2023/9/22 2:54:08] [ConfigManager.js] [INFO]: Started config verification.
[2023/9/22 2:54:08] [ConfigManager.js] [INFO]: Finished config verification. No error was found.
[2023/9/22 2:54:08] [LocaleManager.js] [INFO]: Loading locale data...
[2023/9/22 2:54:08] [LocaleManager.js] [INFO]: Finished loading locale data.
[2023/9/22 2:54:08] [MinecraftDiscordChatSync.js] [INFO]: Finished loading.
[2023/9/22 2:54:08] [plugins/Advancements.js] [INFO]: Loading advancements data...
[2023/9/22 2:54:08] [plugins/Death.js] [INFO]: Loading death message data...
[2023/9/22 2:54:08] [LogObserver.js] [INFO]: Started log observation.
[2023/9/22 2:54:08] [BotManager.js] [INFO]: Logging in to bot...
[2023/9/22 2:54:08] [BotManager.js] [ERROR]: Failed to login because provided token was invalid.

Install

From npm

Just type following command in your Node.js project.

npm install @gakuto1112/nodejs-logger

From GitHub repository

  1. Download or clone GitHub repository.
    • You can download repository files by clicking green "<> Code" button in the upper right corner of the GitHub page.
  2. Open terminal.
  3. Set current directory to this project.
  4. Type npm install to install dependencies.
  5. type npm pack to make a package.
  6. Set current directory to your project.
  7. Type npm install <path_to_package_file> to install this module.

Usage

const logger = require("@gakuto1112/nodejs-logger");

/* Debug log. Won't be outputted by default. */
logger.debug("Debug log");

/* Information log.*/
logger.info("Information log");

/* Warning log.*/
logger.warn("Warning log");

/* Error log.*/
logger.error("Error log");

Options

You can change log style by setting module options.

rootPath

The origin path that used to output relative path from it to caller path when outputting logs. It must be a valid path and a directory path. Otherwise, this module will throw InvalidPathError.

The initial value is the current directory of the terminal. You don't have to change this until you want to change module root path.

setRootPath() is an asynchronous function. Please make sure not to call log function until it returns resolve.

const logger = require("@gakuto1112/nodejs-logger");

/* This log includes the current directory of the terminal. */
logger.info("Prints current directory");

/** Changes module root path. */
logger.setRootPath("/path/to/new/root/path").then(function () => {
   /* This log includes the new root directory. */
   logger.info("Prints new root directory");
});

coloredLog

This option colors log level strings. It makes logs easy to see. However, it is recommended to turn of this option if the log is outputted to the text file (because control characters are outputted as normal characters).

Default value is false.

const logger = require("@gakuto1112/nodejs-logger");

/* Turn on the colored log feature. */
logger.setColoredLog(true);

/* This log will be colored. */
logger.info("Colored log");

setLogDebugLevel

This option determines whether debug level logs should be outputted or not.

Default value is false.

const logger = require("@gakuto1112/nodejs-logger");

/* This log won't be outputted. */
logger.debug("First debug log");

/* Turn on the debug logs. */
logger.setLogDebugLevel(true);

/* This log will be outputted. */
logger.debug("Second debug log");

License

This package is licensed under the MIT License. You are free to use it within the scope of the license.

Keywords

logger