mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-03-22 12:05:20 +00:00
Document resin/log
This commit is contained in:
parent
6b3042760e
commit
3d02acaf20
@ -1,28 +1,82 @@
|
||||
_ = require('lodash')
|
||||
|
||||
# @nodoc
|
||||
isQuiet = false
|
||||
|
||||
# Change log quietness
|
||||
#
|
||||
# @param {Boolean} quiet quietness
|
||||
#
|
||||
# @note If quiet is true, only resin.log.info will be quieted
|
||||
#
|
||||
# @example Set quietness
|
||||
# resin.log.setQuiet(true)
|
||||
#
|
||||
exports.setQuiet = (quiet) ->
|
||||
isQuiet = !!quiet
|
||||
|
||||
# Check quietness
|
||||
#
|
||||
# @return {Boolean} is quiet
|
||||
#
|
||||
# @example Check quietness
|
||||
# resin.log.isQuiet()
|
||||
#
|
||||
exports.isQuiet = ->
|
||||
return isQuiet
|
||||
|
||||
# stderr
|
||||
# Log an error
|
||||
#
|
||||
# @param {...String} message message
|
||||
#
|
||||
# @example Log an error
|
||||
# resin.log.error('Something went wrong!')
|
||||
#
|
||||
exports.error = (args...) ->
|
||||
console.error.apply(null, args)
|
||||
|
||||
# Log a warning
|
||||
#
|
||||
# @param {...String} message message
|
||||
#
|
||||
# @example Log a warning
|
||||
# resin.log.warning('Something might happened!')
|
||||
#
|
||||
exports.warning = (args...) ->
|
||||
console.warn.apply(null, args)
|
||||
|
||||
# stdout
|
||||
# Log info
|
||||
#
|
||||
# @param {...String} message message
|
||||
#
|
||||
# @example Log info
|
||||
# resin.log.info('Look!')
|
||||
#
|
||||
exports.info = (args...) ->
|
||||
return if exports.isQuiet()
|
||||
console.info.apply(null, args)
|
||||
|
||||
# Log out
|
||||
#
|
||||
# @param {...String} message message
|
||||
#
|
||||
# @note This will not be quieted even if setQuiet is set to true
|
||||
#
|
||||
# @example Log out
|
||||
# resin.log.out('Hello World!')
|
||||
#
|
||||
exports.out = (args...) ->
|
||||
console.log.apply(null, args)
|
||||
|
||||
# Log an array
|
||||
#
|
||||
# It will iterate trough the array, calling logFunction for every item
|
||||
#
|
||||
# @param {Array} array array
|
||||
# @param {Function} logFunction log function (e.g: resin.log.info)
|
||||
#
|
||||
# @throw Will throw if logFunction is not a function
|
||||
#
|
||||
exports.array = (array, logFunction) ->
|
||||
return if not array?
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user