Skip to content
Permalink
Browse files

Merge pull request #6 from lolwhoami/master

allow a string prefix
  • Loading branch information...
bahamas10 committed Feb 22, 2019
2 parents ea86344 + 492a399 commit 779acae1a4e159a65d277f9d5e1e55ef3ab44b7c
Showing with 21 additions and 2 deletions.
  1. +14 −0 README.md
  2. +7 −2 log-timestamp.js
@@ -32,6 +32,20 @@ yields
date="2012-08-23T20:08:37.000Z" message="hello world"
```

Also you can specify a custom prefix string

``` js
require('log-timestamp')('#WHATEVER');
console.log('hello world');
```

yields

```
#WHATEVER [2012-08-23T20:08:37.000Z] hello world
```


Install
------

@@ -6,8 +6,13 @@ module.exports = patch;

patch(); // patch when require'd

function patch(fn) {
logprefix(fn || timestamp);
function patch(prefix) {
if(typeof prefix === 'function')
logprefix(prefix);
else if(typeof prefix === 'string' && prefix)
logprefix(() => prefix + ' ' + timestamp());
else
logprefix(timestamp);
}

// the default date format to print

0 comments on commit 779acae

Please sign in to comment.
You can’t perform that action at this time.