Add Custom Colors And Styles To Console Logs With Colorlog.js

Category: Javascript | August 28, 2023
Author:Clevis22
Views Total:25 views
Official Page:Go to website
Last Update:August 28, 2023
License:MIT

Preview:

Add Custom Colors And Styles To Console Logs With Colorlog.js

Description:

Colorlog.js is a tiny and easy JavaScript utility to easily customize console output with color, sizing, backgrounds, and more.

How to use it:

1. Include the colorlog.js script in your HTML file:

<script src="/src/colorlog.js"></script>

2. Log messages using colorlog() instead of console.log(). Available parameters:

  • text (required): the message text
  • color (required): CSS color value for text
  • textSize (optional): font size
  • backgroundColor (optional): background color
  • showTimestamp (optional): show timestamp or not
// colorlog(text, color, [textSize], [backgroundColor], [showTimestamp])
colorlog('Your Text', 'red', '24px', '#ff0000', true);

3. The library also supports different log levels:

colorlog.info(text, color, [textSize], [backgroundColor], [showTimestamp])
colorlog.success(text, color, [textSize], [backgroundColor], [showTimestamp])
colorlog.warn(text, color, [textSize], [backgroundColor], [showTimestamp])
colorlog.error(text, color, [textSize], [backgroundColor], [showTimestamp])

You Might Be Interested In:


Leave a Reply