0.3.0 • Published 5 years ago

pretty-console-logs v0.3.0

Weekly downloads
12
License
MIT
Repository
github
Last release
5 years ago

pretty-console-logs

Home

Install

yarn add pretty-console-logs

npm install pretty-console-logs --save

Naming conventions used

Home

  • Badge text refers to the text with a colored background
  • Message text refers to the text with the transparent background and to the right of the Badge text.

Usage

Message type usage

const { info } = require('pretty-console-logs');

info( <message-text-1>, <message-text-2> ... )               // 'INFO' is set as <badge-text>
info.b( <only-badge-style-text-1>, <only-badge-style-text-1>, ... )    // Only badge style text, no message text
info.m( <only-message-style-text-1>, <only-message-style-text-2> ... )  // Only message style text, no badge text
info.bm( <badge-text>, <message-text-1>, <message-text-2> ... ) //

Same applies to warn, log, error or any custom defined types.
Sample usage
const { info, warn, log, error, indent } = require('pretty-console-logs');

info('Lorem ipsum dolor sit amet');
info.d('Lorem ipsum dolor sit amet'); // Same as above
info.bm('Lorem', 'Lorem ipsum dolor sit amet'); // bm - Badge and Message
info.m('Lorem ipsum dolor sit amet'); // message style text only
info.b('Lorem ipsum dolor sit amet'); // badge type text only
const { info, warn, log, error } = require('pretty-console-logs');

Indentation in the console

You can either use indent independently or use the inbuilt indentation functions in all the message types (using cascading)

Inbuilt indentation

warn.nl(1)
	.tab(TAB_LENGTH)
	.d('Lorem ipsum dolor sit amet')
	.nl(2);

Using 'indent' object

This function is used to position the cursor according to your choice using

  1. nl - newline (/n)
  2. tab - tab (/t)
  3. space - space (' ')

The inner functions are cascaded.

const { indent } = require('pretty-console-logs');

warn.b('Lorem ipsum dolor sit amet');
indent
	.nl(2) // New Line
	.tab(3) // Tab Space
	.space(5); // Space
error.b('Lorem ipsum dolor sit amet');

Indent

TODO

  • Add table cli like create-react-app
  • Divider - dotted, dashed

License

MIT