Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

loggin-js

loggin-js119MIT1.9.0TypeScript support: included

A customizable and expandable logger for NodeJS and the browser

logging, logger, severity, filtering, nodejs, logs, file, remote, file, js, colored, http, memory, expandable, browser, customizable

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):


Manolo Edge

💻 🤔 🚧 ⚠️

Floki

📖

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.

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

1.9.0 (2020-08-29)

Features

  • added strict mode to Severity, when true it will pass throught just same level severity (637e220)

Bug Fixes

  • added default severity, equals debug (bab2360)
  • added missing logger method .default (0d7b3f6)

1.8.0 (2020-01-26)

Features

  • added strict mode to Severity, when true it will pass through just same level severity (ad06c5c)

1.7.2 (2020-01-18)

1.7.3 (2020-01-19)

Bug Fixes

  • severity filtering broke, all logs were logged (7f3d572)

1.7.2 (2020-01-18)

1.7.1 (2020-01-18)

Bug Fixes

  • adding deprecated warning for browser version in import, and in README (960011f)

1.7.0 (2020-01-02)

Features

  • Deprecated RemoteNotifier in favor of HttpNotifier (4c41167)
  • Added Http notifier for browser, renamed Remote notifier to Http (2627db6)

Bug Fixes

  • AdditionalNotifiers: added correct names to notifiers (c40aef4, 425233c)
  • Logger: fixed superfluous argument passed into new Logger in Logger.clone (e793865)

1.6.0 (2019-12-21)

Bug Fixes

  • Logger: fixed superfluous argument passed into new Logger (e793865)
  • Notifier: improved .canOutput method, to accept a ignore function to be passed as an option (cb53fb1)

Features

  • Notifier: pipes can be passed in as options to constructor

1.5.2 (2019-11-21)

1.5.1 (2019-11-21)

Bug Fixes

  • FileNotifier: super call missing?? (d2ee16e)

1.5.0 (2019-11-21)

Features

  • Notifier: Added .enabled method

Bug Fixes

  • examples: added runkit link to file notifier example (ce27a2a)
  • examples: improved examples (b4548c4)
  • logger: changed option for a changed option in notifier (c60a7d1)
  • readme: some changes and referenced json formatter (e67da81)
  • readme: some readme fixes (f35460c)
  • types: added missing Notifier.enabled method (4aec5be)
  • added build browser dist to build script (249a1bd)

1.4.1 (2019-11-13)

Bug Fixes

  • added standard-version package to manage releasing (14a6747)

v1.2.4

  • notifiers can be activated ad deactivated individualy
  • notifiers can have custom names now

v1.2.0

Browser version added, still limited

v1.1.0

This is the "Plugin" version, it adds somewhat of a plugin support and mode customization, now you can:

  • Extend severities
  • Extend notifiers
  • Extend formatters
  • Extend loggers
  • Add plugin to LogginJS

v1.0.0

  • Re-Write of the library
  • Better typings
  • More customizable
  • More tests
  • Better docs