log-segment
Advanced tools
Comparing version 1.5.1 to 1.6.0
11
main.js
@@ -69,2 +69,4 @@ 'use strict' | ||
const __chrono = {} | ||
/** | ||
@@ -574,2 +576,10 @@ * @constructor | ||
const chrono = function (tag, reset) { | ||
if (!__chrono[tag] || reset) { | ||
__chrono[tag] = Date.now() | ||
return | ||
} | ||
return '[' + tag + ' +' + (Date.now() - __chrono[tag]) + ' ms]' | ||
} | ||
__init(params) | ||
@@ -597,2 +607,3 @@ | ||
Log.prototype.value = Log.prototype.val = Log.prototype.v = value | ||
Log.prototype.chrono = chrono | ||
@@ -599,0 +610,0 @@ Log.prototype.mode = mode |
{ | ||
"name": "log-segment", | ||
"version": "1.5.1", | ||
"version": "1.6.0", | ||
"description": "logger with partition", | ||
@@ -5,0 +5,0 @@ "main": "main.js", |
@@ -8,7 +8,7 @@ # log-segment | ||
Javascript logger with partition | ||
javascript logger with partition | ||
## Purpose | ||
Why Another Log Module? Because not all logs are equal. | ||
Not all logs are equal. | ||
I'd like to use a pliable tool to quickly manage logs by two factors: **level** and **segment**. | ||
@@ -19,3 +19,3 @@ | ||
````bash | ||
$ npm i log-segment | ||
$ npm i log-segment --save | ||
```` | ||
@@ -25,3 +25,3 @@ | ||
``log-segment`` is single-ton, so just require and use everywhere. | ||
``log-segment`` is singleton, so just require and use everywhere. | ||
@@ -31,10 +31,10 @@ ````js | ||
const sql = 'INSERT INTO table ...' | ||
log.info('sql', 'executing query ...', log.value('sql', sql)) | ||
const sql = 'INSERT INTO users (username, name) VALUES ($1, $2)' | ||
log.info('sql', 'create user', log.value('sql', sql), log.chrono('insert-user')) | ||
db.query(sql) | ||
.then(() => { | ||
log.success('sql', 'query done.', log.value('sql', sql)) | ||
log.success('sql', 'user created.', log.value('sql', sql), log.chrono('insert-user')) | ||
}) | ||
.catch((err) => { | ||
log.error('sql', 'query error', log.value('sql', sql)) | ||
log.error('sql', 'user not created', log.value('sql', sql), log.value('error', err), log.chrono('insert-user')) | ||
}) | ||
@@ -288,2 +288,6 @@ ```` | ||
v. 1.6.0 | ||
- Add chrono function ``log.chrono('tag')`` | ||
v. 1.3.0 | ||
@@ -307,9 +311,8 @@ | ||
- add chrono > ``log.chrono('tag')`` | ||
- custom format for each level (ex. add trace only in panic) | ||
- browser support, only console mode (!colors) ``console.log('%c message', 'color: red');`` | ||
- custom mode: stream, (sms, telegram and whatever) | ||
- custom format in log.value | ||
- multiple mode for each setting (example: on panic send email + log to file + send sms + call mom) | ||
- (evaluate) support workers (as transport) | ||
- [ ] custom format for each level (ex. add trace only in panic) | ||
- [ ] browser support, only console mode (!colors) ``console.log('%c message', 'color: red');`` | ||
- [ ] custom mode: stream, (sms, telegram and whatever) | ||
- [ ] custom format in log.value | ||
- [ ] multiple mode for each setting (example: on panic send email + log to file + send sms + call mom) | ||
- [ ] (evaluate) support workers (as transport) | ||
- [pino](https://github.com/pinojs/pino) | ||
@@ -316,0 +319,0 @@ - [npmlog](https://github.com/npm/npmlog) |
23554
545
345