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

@reason-native/console

v0.1.0

Published

No effort, universal logger

Downloads

363

Readme

Console: No effort, universal logger.

Part of the reason-native native utility collection.

Using:

  • From your project, add a package dependency on @reason-native/console
  • If using Dune, add an entry in your dune file's libraries section so that it includes console.lib such as: (libraries console.lib )

Browser Inspired: Console is modelled after the browser console. It doesn't require that you define any printers, and Console.log/warn/error accept any type of input. Record fields and variant label names are lost at compile time so they aren't printed.

Suitable For Developers or Users:

  • Passing a single string (as in Console.log("hello")) will not print the quotes (just like in the browser)
  • Passing a deep structure will print the deep structure, and strings that appear in the deep structure will include quotes.

This makes Console suitable for either logging messages displayed to the user in command line apps, but also suitable for messages intended only for the developer to read.

No Effort: Uses runtime checks to determine a likely appropriate printer for your data without requiring any ppx plugins and without having to write printers for your data types. Depth checking will prevent cyclical data from printing infinitely.

Best effort: The basic data types are detected accurately at runtime(string, float, int).

Record labels and variant names are not preserved at compilation time so are not printed - but their data is still printed in the correct order. Records/variant types that occupy more than one word in a block are all printed as their corresponding integer (if a payloadless variant), or {x, y, ...z} for a record or variant that contains data.

Console.log(Some("hi"));
> {"hi"}

Console.log(None);
> 0

Extensible: Allows customization of printing in order to change where the logs are written to, how they are highlighted, and anything else you would like.

Console.log(anything)

Output a string or object to standard output followed by a newline. Suitable for writing to logs, or for outputting user messaging in command line applications. If you pass a string, it will not be wrapped in quotes. If you pass an object, Console.log will attempt to print the object dynamically. Strings deep in objects will be wrapped in quotes.

let log: 'a => unit;

Console.out(anything)

Same as Console.log but attempts to avoid printing a final newline. Not all backends will support omitting the newline (such as in the browser where console only supports outputting with final newlines.)

let out: 'a => unit;

Console.debug(anything)

Same as Console.log but used for developer-facing messaging to standard out. Suitable for writing to log files. In production mode, would typically be suppressed entirely. Custom Console.t implementations may implement custom behavior for Console.debug that behaves differently from Console.log.

let debug: 'a => unit;

Console.error(anything)

Same as Console.log but writes to stderr.

let error: 'a => unit;

Console.warn(anything)

Currently the same as Console.error but will eventually be able to be suppressed via a "log level".

let warn: 'a => unit;