1.2.2 • Published 4 years ago

ttlog v1.2.2

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

ttlog (tagged template log)

Terminal and browser console colorizer

Ttlog console.log()s using tagged template syntax similar to chalk.js, but works in both the browser and terminal (Windows 10, unix/linux, and macOS). Ttlog also returns the plain-text string without colorization information so you can output it to a file or whatever.

Usage in node.js or webpack

const log = require('ttlog');
log`hello {white.bgBlack darkness} {underline my} {green old} {underline.blue.bgYellow friend}`;

Both outputting and writing a log in node.js

const fs = require('fs');
const log = require('ttlog');
fs.appendFile('mylog.log', log`{blue ${Date.now()}}: {green Bad things happened!!}`);

Usage in the browser

Put this in your html (head or body) if you host the file yourself:

<script src="ttlog.min.js"></script>

Use it like this in a .js or <script> tag:

log`hello {white.bgBlack darkness} {underline my} {green old} {underline.blue.bgYellow friend}`;

API

  • red
  • green
  • blue
  • cyan
  • magenta
  • yellow
  • black
  • white
  • bgRed
  • bgGreen
  • bgBlue
  • bgCyan
  • bgMagenta
  • bgYellow
  • bgBlack
  • bgWhite
  • underline

Todo

  • Support console.info/warn/etc? - Problem is node doesn't support those, so it won't be consistent behavior
  • Support import - import and require are competing and I haven't found a way to allow both from the same .js file

Further reading and interesting links

1.2.2

4 years ago

1.2.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago