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

loggin-js

v1.9.0

Published

A customizable and expandable logger for NodeJS and the browser

Downloads

185

Readme

NPM Version Downloads Dependencies Known Vulnerabilities
NPM Package Quality NPM Package Size All Contributors

An easy and customizable logger for NodeJS and the Browser.
If you want to log easily or create some complex loggin system, this might be the tool for you!


🔧 Demo 📓 Wiki
🔗 Logger 🔗 Notifier 🔗 Log 🔗 Severity 🔗 Formatter
🔗 .logger 🔗 .notifier 🔗 .severity 🔗 .formatter


News

  • Browser support is beeing deprecated, development will be discontinued and will be removed from Loggin'JS in version 2.0.0. It's beeing deprecated because it's limiting me on the features I could be adding to the NodeJS version.

Table Of Content

Usefull links:

Installing

$ npm i loggin-js
# or
$ yarn add loggin-js

Importing

const loggin = require('loggin-js');
// Or
import * as loggin from 'loggin-js';

Browser

!! NOTICE !!

Loggin'JS can be used in the browser, but it's still in it's early stages, and the API may change or have errors.

It is also limited. For now, only the console notifier works. Color is not working either!

<!-- Import from node_modules -->
<script src="node_modules/loggin-js/dist/loggin.js"></script>

<script>
  LogginJS.logger();
</script>

You can also use a CDN:

<script src="https://cdn.jsdelivr.net/npm/loggin-js@latest/dist/loggin.js"></script>

Getting Started

The default logger is the simplest way to use Loggin'JS.

loggin.debug(
  'Check this log out!!',
  { foo: 'var' },
  { channel: 'my-logger' }
);

Example Output 1

Additionaly you can create a custom logger:

const logger = loggin.logger({
  level: loggin.severity('info'), // Will output only info level and below
  channel: 'demo-1',
  formatter: 'long',
});

logger.user('Jhon');
logger.color(true);

logger.debug('Debug message, will not output');
logger.info('Info message, will output');

// You can override options when executing .log or any default methods (ie: debug, info, etc...)
logger.error('There was an <%rERROR>', null, { user: 'Bob' });

You can also log to a file:

const logger = loggin.logger('file');
logger.channel('my-logger');

logger.getNotifier('file').pipe(loggin.pipe('DEBUG', './debug.log'));

loggin.debug('Check this log out!!', { foo: 'var' });

Or output log in JSON format:

const logger = loggin.logger({
  formatter: 'json',
});

logger.error('this is an error');

There are a couple of default Notifiers available:

  • NodeJS: file, console, http, memory
  • Browser: console, http

Chek out the wiki for a more detailed guide.

back to top


Examples

Here are some usage examples:

If you want to add an example or find some error, leave an issue or send in a PR.

Plugins

Coming:

  • Telegram
  • Mail - maybe?
  • Sentry, and similar
  • ...

Coverage

Coverage Coverage Coverage Coverage

Contributing

First off, thank you for considering contributing to Loggin'JS.

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests. There is also a public slack channel available.

Contributors ✨

Initial work by nombrekeff

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

License

This project is licensed under the MIT License - see the LICENSE.md file for details.