logger

A zero-dependency TypeScript logger with levels, child contexts, formatters and transports. The real package runs on this page. Send a record, and see where it goes.

The path of the selected record

Records

Sent
0
Passed
0
Dropped
0
Failed writes
0

    What each transport received

    Console

      Memory

      0 entries

        Callback

          Batch

          Open

          Waiting 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

                1. The filter. Logger.log compares the two levels first. If the level of the record is more verbose, the call returns. The logger makes nothing.
                2. The entry. The logger makes one LogEntry with the level, the message, the time, the context, the data and the error.
                3. 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.
                4. 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 batch transport

                API

                Each result below comes from a call of the package when this page opened.

                NameWhat it doesLive 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.");