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

static-console

v1.0.2

Published

Keep structure of the messages and log them to any output, using specific plugins.

Downloads

18

Readme

static-console

Keep structure of the messages and log them to any output, using specific plugins.

Gitter

Install

$ npm install static-console --save --only=production

Recommended option --only=production to skip installation of testing environment. If you want to test it, don't put this option.

API

StaticConsole

const c = require('static-console');

logt(type, ...obj)

Log message with data ...obj under specified type.

type - message type name. null value means that message has regular type.

...obj - parameters that represent the whole message separated by commas

c.logt('special-message-type', `This message is printed under specific type`);
c.logt('multiple-objects', `PI value:`, Math.PI);

It will output:

This message is printed under specific type
PI value: 3.141592653589793

log(...obj)

Same as c.logt(null, ...obj).

error(...obj)

Same as c.logt('error', ...obj).

warn(...obj)

Same as c.logt('warn', ...obj).

info(...obj)

Same as c.logt('info', ...obj).

silly(...obj)

Same as c.logt('silly', ...obj).

trace(title)

Same as c.logt('trace', c.traceStr(title)).

traceStr(title)

Returns stack trace for your debug needs. title replaces caption on first line, by default it will be Trace.

reset(namespace, displayTitle, params)

Set namespace for all next messages.

namespace - string or undefined. When defined string, represents namespace. When undefined, messages gonna be printed in global namespace.

displayTitle - string with display title for last name.

params - object with other options for last name. Very optional.

Namespace is splitted by c.namespaceNestingSymbol ('-' by default) to inherited names, so you can return to parent name without specifying displayTitle and params again.

c.reset('module', `My module`);
c.log(`Welcome to 'module' namespace!`);

c.reset('module-task1', `Special task`);
c.log(`Initializing awesome...`);

c.reset('module-task2', `Task #2`);
c.log(`Washing dishes...`);
c.log(`Preparing table...`);

c.reset('module');
c.log(`I'm done`);

c.reset();
c.log(`I think 'My module' done with it!`);

It will output:

[My module] Welcome to 'module' namespace!
[My module » Special task] Initializing awesome...
[My module » Task #2] Washing dishes...
[My module » Task #2] Preparing table...
[My module] I'm done
I think 'My module' done with it!

namespaceNestingSymbol

String with character that is used to split namespace to names.

c.namespaceNestingSymbol = '-';// Default value
c.reset('first-second-thirdName');
c.log();
// Will output: [first » second » thirdName]

namespace

Array containing names data, that are sent to routers. Automatically set by c.reset.

models, outputs, routers

Built-in objects

RawModel, StdOutput, FileOutput, StdRouter

Built-in classes

What are models, outputs and routers?

Separation of these concerns in module makes it possible to keep structure of sending messages to any elements of user interface.

Models - such objects that are used to convert ...obj to data, that is used in majority of outputs.

Outputs - such objects that are used to print every message to expected place. You can also think about them as "views".

Routers - such objects that are used to send data to multiple outputs with any models. You can also think about them as "controllers".

By default there is c.routers.std that is instance of StdRouter.

Standard router has task to send data about every income message to c.outputs.std that is instance of StdOutput. That data is converted by c.models.raw that is instance of RawModel.

Standard solution

Default solution is bundled with StaticConsole: RawModel, StdOutput, FileOutput, StdRouter.

FileOutput is not initialized by default, but it must work. So you can print to c.outputs.std and instance of FileOutput at same time.

Test

npm test

or

ava --verbose test/MainTest.js

To make tests work, you'll probably need to have local copy of ava package in your node_modules.

Make your own solution

If you want to make your own model, output or router class, proceed to source code of module and copy standard solution's directories (RawModel, StdOutput, StdRouter).

Also try static-console with these plugins:

Outputs:

Find other plugins.