1.0.4 • Published 4 years ago

@eaboy/clean-console v1.0.4

Weekly downloads
7
License
MIT
Repository
github
Last release
4 years ago

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.

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.

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:

NameTypeDefaultDescriptionExample
excludeMethodsarrayPass an array of strings with the console methods you want to keep seeing on the consoleexcludeMethods: ['error', 'info', 'clear']
clearOnInitbooleanfalseSet it to true if you want to clear console before cleanConsole runs, useful if there are logs printed before the library it's initializedclearOnInit: true
debugLocalStoregeKeystringSet the local storage key that you want to use to block the execution of the library and be able to see all logs for debuggingdebugLocalStoregeKey: 'my_awesome_site_key'
initialMessagesarrayPass 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 displayinitialMessages: { 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;' }