See #296. Add package option for setting logger level
This commit is contained in:
parent
52d67cd0f3
commit
d1b0e6d66d
|
@ -344,6 +344,11 @@ plugin.config = _.merge(
|
|||
type: 'string'
|
||||
default: ""
|
||||
description: "Unique identifier for this user for tracking usage analytics"
|
||||
_loggerLevel:
|
||||
type: 'string'
|
||||
default: 'warn'
|
||||
description: 'Set the level for the logger'
|
||||
enum: ['verbose','debug','info','warn','error']
|
||||
beautifyOnSave:
|
||||
type: 'boolean'
|
||||
default: false
|
||||
|
|
|
@ -12,11 +12,24 @@ module.exports = do ->
|
|||
writable = new stream.Writable({
|
||||
write: (chunk, encoding, next) ->
|
||||
msg = chunk.toString()
|
||||
# console.log msg
|
||||
# console.log(msg)
|
||||
emitter.emit('logging', msg)
|
||||
next()
|
||||
})
|
||||
|
||||
levels = {
|
||||
silly: 0,
|
||||
input: 1,
|
||||
verbose: 2,
|
||||
prompt: 3,
|
||||
debug: 4,
|
||||
info: 5,
|
||||
data: 6,
|
||||
help: 7,
|
||||
warn: 8,
|
||||
error: 9
|
||||
}
|
||||
|
||||
return (label) ->
|
||||
transport = new (winston.transports.File)({
|
||||
label: label
|
||||
|
@ -34,6 +47,16 @@ module.exports = do ->
|
|||
transport
|
||||
]
|
||||
})
|
||||
wlogger.on('logging', (transport, level, msg, meta)->
|
||||
loggerLevel = atom.config.get('atom-beautify._loggerLevel')
|
||||
# console.log('logging', loggerLevel, arguments)
|
||||
loggerLevelNum = levels[loggerLevel]
|
||||
levelNum = levels[level]
|
||||
if loggerLevelNum <= levelNum
|
||||
path = require('path')
|
||||
label = path.basename(transport.label)
|
||||
console.log("#{label} [#{level}]: #{msg}", meta)
|
||||
)
|
||||
# Export logger methods
|
||||
loggerMethods = ['silly','debug','verbose','info','warn','error']
|
||||
logger = {}
|
||||
|
|
Loading…
Reference in New Issue