Files
cypress/packages/server/lib/gui/logs.coffee
T
2017-05-09 13:51:45 -04:00

29 lines
558 B
CoffeeScript

chalk = require("chalk")
logger = require("../logger")
module.exports = {
get: ->
logger.getLogs()
clear: ->
logger.clearLogs()
off: ->
logger.off()
onLog: (fn) ->
logger.onLog(fn)
error: (err) ->
## swallow any errors creating this exception
logger.createException(err).catch(->)
print: ->
## print all the logs and exit
@get().then (logs) ->
logs.forEach (log, i) ->
str = JSON.stringify(log)
color = if i % 2 is 0 then "cyan" else "yellow"
console.log chalk[color](str)
}