The main logger.
Optional
Rest
...moreLoggers: AsyncLoggerMiddleware[]An optional list of more loggers.
The new middleware.
import log, { AsyncLoggerMiddleware, useAll } from "@egomobile/log"
const myFirstMiddleware: AsyncLoggerMiddleware = (type, args, next) => {
try {
// do your stuff here
next() // tell the iteration, that we are finished here
} catch (error) {
next(error) // you can explicitly tell the iteration
// that some failed here and we need to execute
// the upcoming fallback
}
}
// is called after 'myFirstMiddleware' has
// called 'next()' without errors
const mySecondMiddleware: AsyncLoggerMiddleware = (type, args, next) => {
// do your stuff here
//
// if something fails here and throws an error
// it is the same thing as calling 'next(error)'
next() // tell, that we are OK here
}
// is called after 'mySecondMiddleware' has
// called 'next()' without errors
const myThirdMiddleware: AsyncLoggerMiddleware = (type, args, done) => {
// do your stuff here
done()
}
log.use( useAll(myFirstMiddleware, mySecondMiddleware, myThirdMiddleware) )
log('foo')
Generated using TypeDoc
Creates a middleware, that tries to execute all loggers in a chain, using a 'next function'.