Skip to content

Evaluate console.log format specifiers before logging

Notifications You must be signed in to change notification settings

alloc/log-format

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@alloc/log-format

Evaluate console.log format specifiers (eg: %O) before logging.

Format specifiers:

  • %O Use pretty-format before insertion
  • %s Use String(value) before insertion
  • %f Use Number(value) before insertion
  • %d Use Math.floor(value) before insertion (alias: %i)

Example

import format from '@alloc/log-format'

format('a: %O, b: %O', /.+/, new Date)
// => 'a: /.+/, b: 2020-06-26T18:39:40.258Z'

format({ a: [1, 2], b: new Set([3, 4]) })
// => '{"a": [1, 2], "b": Set {3, 4}}'

About

Evaluate console.log format specifiers before logging

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published