monolog
Version:
Log with Monolog
57 lines (53 loc) • 1.67 kB
text/coffeescript
Logger = require '../Logger'
LineFormatter = require '../formatter/LineFormatter'
class AbstractHandler
###
Base Handler class providing the Handler structure
###
constructor:(=Logger.DEBUG,=true)->
= []
###
Checks whether the given record will be handled by this handler.
This is mostly done for performance reasons, to avoid calling processors for nothing.
Handlers should still check the record levels within handle(), returning false in isHandling()
is no guarantee that handle() will not be called, and isHandling() might not be called
for a given record.
{Array} record
{Boolean}
###
isHandling:(record)->
record.level>=
###
handle a record
{monolog.Record} record
{Function} cb
{Boolean}
###
handle:(record,cb)->
cb(undefined,undefined,record,this) if cb instanceof Function
false
###
handle an array of records
{Array<Object>} records
{Boolean}
###
handleBatch:(records)->
for record in records ; return
close:->
pushProcessor:(callback)->
.unshift(callback) if callback instanceof Function
popProcessor:()->
.shift();return this
setFormatter:()->
getFormatter:->
= if not then new LineFormatter else
setLevel:()->
getLevel:->
setBubble:()->
getBubble:->
processRecord:(record)->
if
for processor in
record = processor(record)
return record
module.exports = AbstractHandler