From 91637107fb2bc82cb0a9bfe84a5ef9c4d9e43698 Mon Sep 17 00:00:00 2001 From: Kiko Beats Date: Fri, 15 Sep 2017 14:09:19 +0200 Subject: [PATCH] =?UTF-8?q?timestamp=20=E2=86=92=20trace?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 8 ++++---- examples/levels.js | 2 +- lib/Default.coffee | 18 +++++++++--------- test/test.coffee | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index a8687b8..a2f6ea1 100755 --- a/README.md +++ b/README.md @@ -198,7 +198,7 @@ You can completely customize the library to your requirements: changes colors, a By default the messages structure is brief: Just the message type followed by the message itself. -But you can easily modify the output. For example, let's add a timestamp to each message: +But you can easily modify the output. For example, let's add a trace to each message:


@@ -260,7 +260,7 @@ You can provide your own separator or disable it providing a `false`. Default: `false` -Prints timestamp between log from the same level. Specially useful to debug timings. +Prints trace between log from the same level. Specially useful to debug timings. ##### **{Boolean}** color @@ -274,11 +274,11 @@ Default: `false`. Enable or disable print log level in upper case. -##### **{Boolean|Number}** timestamp +##### **{Boolean|Number}** trace Default: `false`. -Prints a numeric counter timestamp associated with each log line. +Prints a numeric counter trace associated with each log line. The value provided is the minimum quantity of time in milliseconds to consider print a different counter. diff --git a/examples/levels.js b/examples/levels.js index 074ad2d..b9bdc44 100644 --- a/examples/levels.js +++ b/examples/levels.js @@ -3,7 +3,7 @@ const Acho = require('..') const acho = Acho({ diff: true, - timestamp: 1000, + trace: 1000, // upperCase: true, context: 'generated' // keyword: 'symbol' diff --git a/lib/Default.coffee b/lib/Default.coffee index ce91751..4000e3f 100644 --- a/lib/Default.coffee +++ b/lib/Default.coffee @@ -33,18 +33,18 @@ module.exports = () -> @align outputCounter: -> - return '' unless @timestamp + return '' unless @trace - @_counterTimestamp ||= 0 - @_lastTimestamp ||= null + @_countertrace ||= 0 + @_lasttrace ||= null - diff = Date.now() - @_lastTimestamp + diff = Date.now() - @_lasttrace - if diff >= @timestamp - ++@_counterTimestamp - @_lastTimestamp = Date.now() + if diff >= @trace + ++@_countertrace + @_lasttrace = Date.now() - " [#{@decorateCounter(@_counterTimestamp)}]" + " [#{@decorateCounter(@_countertrace)}]" outputSeparator: (type) -> return '' if @keyword @@ -126,7 +126,7 @@ module.exports = () -> align: " " color: true - timestamp: 0 + trace: 0 offset: 2 depth: Infinity diff --git a/test/test.coffee b/test/test.coffee index 996f187..576cf17 100755 --- a/test/test.coffee +++ b/test/test.coffee @@ -92,7 +92,7 @@ describe 'acho', -> it 'enabling diff between logs', (done) -> log = acho diff: true - timestamp: true + trace: true printWarn = -> log.warn 'hello world' printErr = -> log.error 'oh noes!'