Class.coffee 490 B

1234567891011121314151617181920212223
  1. class Class
  2. trace: true
  3. log: (args...) ->
  4. return unless @trace
  5. return if typeof console is 'undefined'
  6. args.unshift("[#{@.constructor.name}]")
  7. console.log(args...)
  8. @
  9. logStart: (name, args...) ->
  10. return unless @trace
  11. @logtimers or= {}
  12. @logtimers[name] = +(new Date)
  13. @log "#{name}", args..., "(started)" if args.length > 0
  14. @
  15. logEnd: (name, args...) ->
  16. ms = +(new Date)-@logtimers[name]
  17. @log "#{name}", args..., "(Done in #{ms}ms)"
  18. @
  19. window.Class = Class