@eaboy/clean-console
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

clean-console

A simple library to keep the console of your site or app clean. No more logs, errors, warnings, etc. printed on the console and visible to everybody. You can also show fancy messages to your curious visitors.

clean-console with initial message

And if you want to see the logs for debugging, you can just set a local storage key to true and pass that key as part of the configuration.

clean-console with local storage key

install

npm i @eaboy/clean-console

usage

Default usage:

import { CleanConsole } from '@eaboy/clean-console';

CleanConsole.init() // Dafault behavior

Custom usage:

import { CleanConsole } from '@eaboy/clean-console';

CleanConsole.init(configOptions) // Object parameter for coustom options

You can also load directly clean-console.min.js in your page and call the init method in your code:

cleanConsole.init(configOptions) // Object parameter for coustom options

Configuration options

To customize the behavior you can pass a config object with the following properties. All properties are optional:

Name Type Default Description Example
excludeMethods array Pass an array of strings with the console methods you want to keep seeing on the console excludeMethods: ['error', 'info', 'clear']
clearOnInit boolean false Set it to true if you want to clear console before cleanConsole runs, useful if there are logs printed before the library it's initialized clearOnInit: true
debugLocalStoregeKey string Set the local storage key that you want to use to block the execution of the library and be able to see all logs for debugging debugLocalStoregeKey: 'my_awesome_site_key'
initialMessages array Pass an array of objects with a property message which contains the message that you want to be displayed on the console and, optionally, a property style with the css style that you want to apply to the message. You can pass as many objects as messages you want to display initialMessages: { message: 'Thanks for visiting my awesome site!', style: 'color: red; font-size: 28px; font-weight: bold; font-family: "Comic Sans MS", cursive, sans-serif; line-height: 38px;' }

Package Sidebar

Install

npm i @eaboy/clean-console

Weekly Downloads

24

Version

1.0.4

License

MIT

Unpacked Size

9.04 kB

Total Files

9

Last publish

Collaborators

  • eaboy