npm.io
1.0.3 • Published 2 years ago

console-custom-tag

Licence
MIT
Version
1.0.3
Deps
3
Size
5 kB
Vulns
0
Weekly
0

console-tag

Easier to see personal log in browser.

Installation

npm i -S console-tag

Usage

You need to install it before using it. tag config is required.

        import consoleTag from '/dist/console-tag.bundle.js';
        consoleTag.install({
            enable: true, // false or true
            tag: {
                'test': {
                    tag: {
                        name: '[test-tag]',
                        style: 'color:white;background-color:#ecad9e;border-radius:4px;padding:2px 4px;font-size:12px;'
                    },
                    hook: () => {
                        console.log("I am a hook")
                    }
                }
            }
        });
        console.test('tag sth')

Tag Configuration supports customization.You can config your nickname and colorful tag.

        consoleTag.install({
            enable: true, // false or true
            tag: {
                'custom-name': { // terminate you want
                    tag: {
                        name: '[test-tag]', // tag show in console
                        style: 'color:white;background-color:#ecad9e;border-radius:4px;padding:2px 4px;font-size:12px;'
                    },
                    hook: () => {
                        console.log("I am a hook")
                    }
                }
            }
        });

params

install(config)
params type required description
enable boolean false It will take effect when the value is false, and supports configuration according to the environment.Example: dev debugging environment takes effect, production not install({ enable: env === 'dev' ? true : false })
tag Object true Config commands what you want
 'customName' Object true 'customName' is the command u want. console[customName]
  tag Object true Tag style config
   name String true Tag context
   style String true Tag style
  hook Function false Hook function will be called before custom command.

Keywords