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

yoyolib

v2.4.2

Published

A sample package for logger

Downloads

15

Readme

Stargazers Issues

YoyoLib

YoyoLib is a lightweight library designed for handling logging and multi-language support in your Node.js applications.

Features

  • Logging: Create log messages with customizable formatting and the ability to write logs to files using the Logger class.

  • Multi-language Support: Easily manage multi-language support for your application with the LangManager class.

Installation

npm install yoyolib

Example usage

Logger

// Import the yoyolib
const { createLogger } = require('yoyolib');

// Create a logger instance
const logger = createLogger();

// Print a log on the console
logger.log("test log");

// Print an info on the console
logger.info("test info");

// Print a warn on the console
logger.warn("test warn");

// Print an error on the console
logger.error("test error");

// Print a log with additional options
logger.log({ content: "test log", name: "TEST" });

// Print a log with options to control console and log writing
logger.log({ content: "test log", console: false, log: false });

LangManager

json file


// "en_EN"
{
    "message": {
        "test": "this is a test.",
        "testVariables": "Hello {user} !"
    }
}

// "fr_FR"
{
    "message": {
        "test": "ceci est un test.",
        "testVariables": "Bonjour {user} !"
    }
}

Create a folder named 'lang' and place your language files ('fr_FR.json' and 'en_EN.json') inside.

js

// Import the yoyolib
const { createLangManager } = require('yoyolib');

// Create a multi-language support handler
const langManager = createLangManager();
let message;

// Add a language
langManager.add('en', 'en_EN');
langManager.add('fr', 'fr_FR');

// Set the active language
langManager.set('en');

// Use a multi-language system
message = langManager.use('message.test');
console.log(message); // Output: this is a test.
message = langManager.use('message.testVaraibles', {user: "yoyoazs"});
console.log(message); // Output: Hello yoyoazs !

// Set the active language
langManager.set('fr');

// Use a multi-language system
message = langManager.use('message.test');
console.log(message); // Output: ceci est un test.
message = langManager.use('message.testVaraibles', {user: "yoyoazs"});
console.log(message); // Output: Bonjour yoyoazs !

API

createLogger(logday = false, date = false, args = undefined): Logger

Creates a Logger instance with optional configurations.

  • logday (boolean): If true, creates a log file for the day.
  • date (boolean): If true, logs both date and hours; otherwise, only logs hours.
  • args (object): Additional configuration options for the Logger.

Returns a Logger instance.

createLangManager(): LangManager

Creates a new instance of a multi-language support handler.

Returns a LangManager instance.

License

This project is licensed under the YoyoLib Custom License - see the LICENSE file for details.

For more information, please refer to our wiki