Skip to content

Commit

Permalink
timestamp → trace
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Sep 15, 2017
1 parent 9296cab commit 9163710
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

<p align="center">
<br>
Expand Down Expand Up @@ -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

Expand All @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion examples/levels.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const Acho = require('..')
const acho = Acho({
diff: true,
timestamp: 1000,
trace: 1000,
// upperCase: true,
context: 'generated'
// keyword: 'symbol'
Expand Down
18 changes: 9 additions & 9 deletions lib/Default.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -126,7 +126,7 @@ module.exports = () ->

align: " "
color: true
timestamp: 0
trace: 0
offset: 2
depth: Infinity

Expand Down
2 changes: 1 addition & 1 deletion test/test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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!'
Expand Down

0 comments on commit 9163710

Please sign in to comment.