@marblejs/core defines a pluggable Logger dependency registered by default to the context of every server factory. Having that you can inspect things like, registered context dependencies, mapped HTTP routes, request/response logs, I/O event traces, etc.
Logger
The interface allows you to define the log tag, type, main message and an optional level, which if not defined defaults to LoggerLevel.INFO.
Marble.js logger is an instance of IO monad which represents a synchronous effectful computation. In order to execute the logger you have to "run the IO action".
Logger ::LoggerOptions->IO<void>;
import { LoggerTag, LoggerToken, LoggerLevel, use, r } from'@marblejs/core';import { requestValidator$, t } from'@marblejs/middleware-io';import { tap } from'rxjs/operators';import { UserDto } from'./user.dto';constfoo$=r.pipe(r.matchPath('/foo'),r.matchType('GET'),r.useEffect((req$, ctx) => {constlogger=useContext(LoggerToken)(ctx.ask);constlogMagic=logger({ tag:LoggerTag.HTTP level: LoggerLevel.INFO, type:'foo$', message:'Here the magic happens...', });returnreq$.pipe(tap(logMagic),// .. )); });
Custom logger
You can override the binding and map the stdout IO operations to a different destination (e.g. file or external service) when needed.