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

logifys

v1.0.36

Published

Let's make logs easier!

Downloads

57

Readme

LOGIFYS

npm dependents install size Downloads NPM Version run on repl.it

Installation

yarn add logifys

or

npm install logifys

Usage

To use LOGIFYS, simply import the package and call the log function:

const log = require('logifys');

// log message with default options
log('This is a simple log message');

// log message with custom font, color, background color and size
log('This is a custom log message', {
  font: 'bold',
  color: 'red',
  backgroundColor: 'yellow',
  size: '36px'
});

// log message with file and json options
log('This is a log message with file and json options', {
  font: 'italic',
  color: 'green',
  size: '20px',
  file: './logs.txt',
  json: true
});

Features

LOGIFYS makes logging easier and nicer to look at with its extensive selection of fonts and colors.


Colors

LOGIFYS supports the following colors:

  • Red,
  • Blue,
  • Green,
  • Yellow,
  • Black,
  • Cyan,
  • Magenta,
  • White,
  • Lime,
  • Brown,
  • Pink,
  • Gray,
  • Purple,
  • Orange

Background Colors

LOGIFYS supports the following background colors:

  • Red,
  • Blue,
  • Green,
  • Yellow,
  • Black,
  • Cyan,
  • Magenta,
  • White,
  • Lime,
  • Brown,
  • Pink,
  • Gray,
  • Purple,
  • Orange

| :warning: WARNING | |:---------------------------| | Not all consoles support sizing |

Size

LOGIFYS supports the following sizes:

  • Any number

| :warning: WARNING | |:---------------------------| | JSON Support is in beta, use at your own risk. |

Json Support

LOGIFYS supports jsons:

const log = require('logifys');

// log message with file and json options
log('This is a log message with file and json options', {
  font: 'italic',
  color: 'green',
  size: '20px',
  file: './logs.txt',
  json: true
});

Fonts

LOGIFYS supports the following fonts:

  • Bold,
  • Underline,
  • Italic.

Example

Here is a simple proof of concept for LOGIFYS:

const log = require('logifys');

var points = new Array(100);
for (var i = 0; i < 100; i++) {
    points[i] = i + 1; 
}

for (var i = 0; i < points.length; i++) {
    log(points[i], { font: 'bold', color: 'magenta' }); 
}

This code will produce the following output:

Image


Logging

Here is an example of how the logging to .txt works:

const log = require('logifys');

log('This is an example of logging...', { font: 'bold', color: 'red', file: './log.txt' });

This code will produce the following output:

Image

This code will result it being logged in a .txt file as shown:

Image


Real World Usage

Here is an example of how you might use Logifys in a real world scenario:

const log = require('logifys');
const fs = require('fs');
const https = require('https');

// Your code to fetch data from an API
https.get('https://jsonplaceholder.typicode.com/posts', (res) => {
  let data = '';

  res.on('data', (chunk) => {
    data += chunk;
  });

  res.on('end', () => {
    try {
      const posts = JSON.parse(data);
      log(`Successfully fetched ${posts.length} posts`, { color: 'green', file: './log.txt' });
    } catch (error) {
      log(`Error fetching posts: ${error}`, { color: 'red', file: './log.txt' });
    }
  });
});

// Your code to write to a file
fs.writeFile('./notes.txt', 'Remember to buy milk', (error) => {
  if (error) {
    log(`Error writing to file: ${error}`, { color: 'red', file: './log.txt' });
  } else {
    log(`Successfully wrote to file`, { color: 'green', file: './log.txt' });
  }
});

Web Development Example

Here is an example of how you might use Logifys in a web development scenario:

const log = require('logifys');
const express = require('express');

const app = express();
const port = process.env.PORT || 3000;

app.listen(port, () => {
  log(`Server is listening on port ${port}`, { font: 'bold', color: 'green' });
});

app.get('/', (req, res) => {
  log('Received a request to the root endpoint', { font: 'italic', color: 'blue' });
  res.send('Welcome to the Express server!');
});

app.use((error, req, res, next) => {
  log(`Error: ${error.message}`, { font: 'underline', color: 'red' });
  res.status(500).send('An error occurred, please try again later.');
});