fancy-format-log

Log things, prefixed with a customized format timestamp

Usage no npm install needed!

<script type="module">
  import fancyFormatLog from 'https://cdn.skypack.dev/fancy-format-log';
</script>

README

fancy-format-log

Log things, prefixed with a customized format timestamp

Install

$ npm install fancy-format-log

Usage

const format = require('fancy-format-log')

const options = {
  format: 'YYYY-MM-DD HH:mm:ss:ms',   // Optional - Default is 'HH:mm:ss'
  style: 'dim.green'                  // Optional - Default is 'grey'
}

const f = format(options)

f.log('a message')
f.error('oh no!')

Valid patterns

  • YYYY: full year
  • MM: month
  • DD: day
  • HH: hours
  • mm: minutes
  • ss: seconds
  • ms: milliseconds

Valid styles

See chalk-pipe valid styles.

Example

Here is example.

API

f.log(msg...)

Logs the message as if you called console.log but prefixes the output with the current time.

f.error(msg...)

Logs the message as if you called console.error but prefixes the output with the current time.

f.warn(msg...)

Logs the message as if you called console.warn but prefixes the output with the current time.

f.info(msg...)

Logs the message as if you called console.info but prefixes the output with the current time.

f.dir(msg...)

Logs the message as if you called console.dir but prefixes the output with the current time.

Related

  • chalk-pipe - Create chalk style schemes with simpler style strings
  • fancy-log - Log things, prefixed with a timestamp

License

MIT © LitoMore