Skip to content

Commit

Permalink
possibility to decide where put diff in the output
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Oct 15, 2015
1 parent 0a4214f commit bb03a48
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/Acho.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = class Acho

constructor: (options = {}) ->
@keyword = options.keyword
@align = options.align or DEFAULT.ALIGN
@align = if options.align? then options.align else DEFAULT.ALIGN
@timestamp = [] if options.diff or DEFAULT.DIFF
@outputType = options.outputType or DEFAULT.OUTPUT_TYPE
@color = options.color or DEFAULT.COLOR
Expand Down
18 changes: 9 additions & 9 deletions lib/Default.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,34 @@ module.exports =
@transport @generateMessage type, message for message in @messages[type]

OUTPUT_MESSAGE: (message) -> message
OUTPUT_TYPE: (type) ->
type = @keyword or type
if @align and not @timestamp then "#{type}\t " else "#{type} "
OUTPUT_TYPE: (type, diff = '') ->
if @align and not @timestamp then "#{diff}#{type}\t " else "#{diff}#{type} "

TRANSPORT: console.log

GENERATE_MESSAGE: (type, message) ->
return unless @isPrintable type
colorType = @types[type].color
messageType = @outputType(unless @keyword then type)
messageType = @colorize colorType, messageType
message = @outputMessage message
message = @colorize @types.line.color, message
timestamp = ''

if @timestamp
if @timestamp[type]
diff = new Date() - @timestamp[type]
diff = if diff > 10000 then ms diff else "#{diff}ms"
timestamp = @colorize colorType, "+#{diff} "
@timestamp[type] = new Date()
messageType = @outputType @keyword or type, " +#{diff}"
else
@timestamp[type] = new Date()
messageType = @outputType @keyword or type
else
messageType = @outputType @keyword or type

messageType + timestamp + message
messageType = @colorize colorType, messageType
messageType + message

GENERATE_TYPE_MESSAGE: (type) ->
(message) ->
(message) =>
@transport @generateMessage type, message
this

Expand Down

0 comments on commit bb03a48

Please sign in to comment.