The path of the selected record
Records
- Sent
- 0
- Passed
- 0
- Dropped
- 0
- Failed writes
- 0
What each transport received
Transport failures
The hook onTransportError got these failures. The other transports still got the record.
Memory
0 entriesCallback
Batch
OpenWaiting for a flush
Sent
The calls you made
The newest call is first. Each line is a call of the package that the page made for you.
How it works
- The filter.
Logger.logcompares the two levels first. If the level of the record is more verbose, the call returns. The logger makes nothing. - The entry. The logger makes one
LogEntrywith the level, the message, the time, the context, the data and the error. - The transports. The logger gives the same entry to each transport, in sequence. A failed write goes to
onTransportError, and the next transport still runs. - The formatter. Each transport that writes text calls its own formatter. The memory transport keeps the entry and uses no formatter.
How this page watches the logger
- The page imports
src/index.tsof the repository. Each result on this page comes from that code. - A hidden transport sits first on each logger.
Logger.logcalls it only for a record that passes, so the page does not repeat the level check. ConsoleTransportcallsconsole.errorand the other methods. The page catches these calls and shows them. A checkbox also sends them to DevTools.- The package has no call that changes the formatter of a running logger. So the page gives each transport one object, and that object forwards to the formatter that you pick.
- The built-in transports have no
flushorclose. The batch transport below is part of this site, and it uses only the publicTransportinterface.
The batch transport
API
Each result below comes from a call of the package when this page opened.
| Name | What it does | Live result |
|---|
Install
From npm
npm install @mark1russell7/logger
First logger
import { createLogger, createJsonFormatter, LogLevel } from "@mark1russell7/logger";
const log = createLogger({ level: LogLevel.DEBUG, context: "app", formatter: createJsonFormatter() });
const db = log.child("db");
db.info("Connected", { data: { host: "localhost" } });
log.debug("Ready");
log.trace("The level drops this record.");