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

y-log-io

v0.0.5

Published

console loging to an other terminal. Useful to not disturb the main terminal output.

Downloads

1

Readme

y-log-io

Console loging to an other terminal. Useful to not disturb the main terminal output.

This console outputs to an other terminal to avoid disturbing the layout or primary informations of the main terminal output.

Install :

npm install y-log-io

Exemple 1 : base use.

Script 1 : Get your logger (where you execute you code)

const Log= require('y-log-io');
var logger=Log.getlogger(jsonPath);
logger.log('some',{data:{txt:'abcd',list:[0,1,2]}},['a','b','c']);

Script 2 : show output logs.

const Log= require('y-log-io');
var output = Log.getOutput(theSame_jsonPath);
output.start();

See exemple_01.

Menu

Get logger

Get the logger. This command returns an instance of Input.

/**
get the logger.
@param {string} fileName : path to logs json file OR a registered file alias.
@return {Input} the fake console
*/
YLogIO.getlogger(fileName)

Input

- Properties
  • timeout : int default=500.
    • Minimal read/write period. The logger wont access the json file more than once evry timeout ms.
    • Decrease if you want more responsiveness.
    • Increase if you want to limit rw charge.
  • maxlog : int default=100.
    • maximum logs buffer size. Limits json file size when output is not listening.
    • Low value reduce file size and r/w time, but you may loose outputs.
  • fileName : string read only
    • path to the json file name.

Get Output

Get the logger output. This command returns an instance of Output.

/**
get logger output.
@param {string} fileName : path to logs json file OR a registered file alias.
@return {YL.Output} the console output logger. call logger.start(); to activate.
*/
YLogIO.getOutput(fileName)

Output

- Methods
  • .start : Starts the console output.
/**
activate the console.
*/
Output.start();
- Properties
  • timeout : int default=2000.

    • maximal r/w period (fs.watch leaks fix) forced access to json file if no changes have been detected after timeout ms.
  • splitTimeout : int default=2000.

    • display a different log separator when time between log is greater than splitTimeout ms.
  • startMsg : string

    • The message displayed when the output starts.
  • stackMax : int default=5.

    • displayed stack pile maximum size.
  • show : object

    • .startLine : boolean default=true
      • Shows startMsg.
    • .topLine : boolean default=true
      • Shows log separator.
    • .info : boolean default=true
      • Shows log infos (time method file line).
    • .time : boolean default=true
      • Shows log time.
    • .method : boolean default=true
      • Shows log local method.
    • .file : boolean default=true
      • Shows log current file name.
    • .line : boolean default=true
      • Shows log current file line number.
    • .stack : boolean default=true
      • Shows stack pile.

Aliases

Share the same output among files without caring about different pathes by registering an alias.

/**
register an alias name for the logs json file. useful for access in different file pathes.
@param {string} name : alias of the registered file path.
@param {string} fileName : path to logs json file.
*/
YLogIO.register(name,fileName)

The registration could be done only (but at least) once. Event in a one-shot separated script.

const Log= require('y-log-io');
Log.register('my-alias',pathToAJsonFile);

You can now call logger and output by their alias.

ex logger:

const logger= require('y-log-io').getlogger('my-alias');

ex output :

require('y-log-io').getOutput('my-alias').start();

Exemples