mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-20 06:07:55 +00:00
3ff5880ae3
If build is ran through `resin deploy`, then logs will be stored and uploaded to the database, where the dashboard can display them Change-type: minor Signed-off-by: Cameron Diver <cameron@resin.io>
46 lines
1.3 KiB
CoffeeScript
46 lines
1.3 KiB
CoffeeScript
eol = require('os').EOL
|
|
|
|
exports.getLogStreams = ->
|
|
{ StreamLogger } = require('resin-stream-logger')
|
|
colors = require('colors')
|
|
_ = require('lodash')
|
|
|
|
logger = new StreamLogger()
|
|
logger.addPrefix('build', colors.blue('[Build]'))
|
|
logger.addPrefix('info', colors.cyan('[Info]'))
|
|
logger.addPrefix('debug', colors.magenta('[Debug]'))
|
|
logger.addPrefix('success', colors.green('[Success]'))
|
|
logger.addPrefix('warn', colors.yellow('[Warn]'))
|
|
logger.addPrefix('error', colors.red('[Error]'))
|
|
|
|
streams =
|
|
build: logger.createLogStream('build'),
|
|
info: logger.createLogStream('info'),
|
|
debug: logger.createLogStream('debug'),
|
|
success: logger.createLogStream('success'),
|
|
warn: logger.createLogStream('warn'),
|
|
error: logger.createLogStream('error')
|
|
|
|
_.mapKeys streams, (stream, key) ->
|
|
if key isnt 'debug'
|
|
stream.pipe(process.stdout)
|
|
else
|
|
stream.pipe(process.stdout) if process.env.DEBUG?
|
|
|
|
streams
|
|
|
|
exports.logInfo = (logStreams, msg) ->
|
|
logStreams.info.write(msg + eol)
|
|
|
|
exports.logDebug = (logStreams, msg) ->
|
|
logStreams.debug.write(msg + eol)
|
|
|
|
exports.logSuccess = (logStreams, msg) ->
|
|
logStreams.success.write(msg + eol)
|
|
|
|
exports.logWarn = (logStreams, msg) ->
|
|
logStreams.warn.write(msg + eol)
|
|
|
|
exports.logError = (logStreams, msg) ->
|
|
logStreams.error.write(msg + eol)
|