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

logalize

v0.0.7

Published

A better window.console

Downloads

656

Readme

Logalize

Logalize is a JavaScript wrapper for browser's developer console.

Rails gem

Main features

Usage

Enable or disable logging:

// Disable logalize
logalize.configure({ enabled: false })
// Enable logalize only for yourself (writes to localStorage)
logalize.enable()

Methods that work exactly like their console's counterparts:

Also:

logalize.group('group1')
myVar = myFunction()
logalize.groupEnd()

/* is the same as */

myVar = logalize.group('group1', myFunction)

Also:

logalize('my output')
// is the same as:
logalize.log('my output')

Configuration options

logalize.configure({
  enabled: true,
  enableFormatting: true,
  collapseNamespaces: false
})
  • enabled: Defines whether to enable or disable Logalize. When Logalize is disabled, it will not produce any output. However, lambda versions of profile, time, group and namespace will still execute given functions. Default: true.
  • enableFormatting: Defines whether formatting should be enabled. Default: true.
  • collapseNamespaces: Defines whether namespaces should use group or groupCollapsed method. Defaults to false (group).

Namespaces

Namespaces are like groups but more convenient:

/* method 1 */
logalize.namespace('namespace one').log('inside namespace 1')

/* method 2 */
val = logalize.namespace('namespace one', function () {
  logalize.log('inside namespace 1')
  return 'veryImportantValue'
})

You can easily mix methods together and nest namespaces however you want:

logalize.namespace('user login', function () {
  logalize.info('user login started')
  logalize.namespace('credentials').log('credentials are {correct}.green')
  /* code */
  logalize.info('[success].green')
})

logalize.namespace('namespace 1').log('some more output')
logalize.namespace('namespace 1', 'another namespace!').log('still nested correctly')

Output:

Namespace output

Formatting

Logalize supports Markdown-like string formatting. Here's the options:

  • **bold**
  • *italic*
  • ~strikethrough~
  • _underline_
  • [badge text].classOne.classTwo... (classes are optional)
  • {custom text}.classOne.classTwo... (classes are required). This syntax allows you to apply CSS classes to text in curly braces. Available classes are: badge, bold, italic, strikethrough, underline and color classes.

At the moment, you cannot nest formatting options into each other. Objects and functions are not formattable, but they likely will be in the future.

Color classes

Logalize supports following color classes (both for badges and normal text):

  • .blue
  • .orange
  • .red
  • .green
  • .cyan
  • .purple

Adding custom / overriding existing styles

All styles are declared in a stylesheet and thus are easily extensible. See index.scss. At the moment, only these attributes are supported: margin, color, background-color, border-radius, padding, font-weight, font-style, text-decoration.

Known issues

  • There's no way to detect when console output happens. Development tools are separate from window and document, and there is no way to know if the output is happening. So, some output will inevitably get stuck in a group it doesn't belong.

  • Stack traces from logalize.error and logalize.trace contain unneeded information. Since logalize.error and logalize.trace call some functions under the hood, the stack trace produced by those functions will contain several unneeded calls.

All of this is according to the author's research. If you know a solution to any of these problems, you're highly encouraged to open an issue and/or a pull request at akxcv/logalize.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/akxcv/logalize.

License

The package is available as open source under the terms of the MIT License.

TODO

  • Support nested formatting
  • Log history
  • Focus mode (see only the logs you need right now)
  • Object and function formatting