API reference@evolu/commonConsole › ConsoleStoreOutput

Defined in: packages/common/src/Console.ts:345

A ConsoleOutput that stores the latest entry in a ReadonlyStore.

Subscribe to ConsoleStoreOutput.entry to observe all log entries.

Example

import {
  assertOk,
  createConsole,
  createConsoleStoreOutput,
  Data,
  type ConsoleEntry,
} from "@evolu/common";

const storeOutput = createConsoleStoreOutput();
const console = createConsole({ output: storeOutput });
let forwardedEntry: ConsoleEntry | null = null;
const unsubscribe = storeOutput.entry.subscribe(() => {
  forwardedEntry = storeOutput.entry.get();
});

console.child("relay").info("connected");
unsubscribe();

assertOk(Data.fromUnknown(forwardedEntry), {
  method: "info",
  path: ["relay"],
  args: ["connected"],
});

Extends

Properties

entry

readonly entry: ReadonlyStore<
  | ConsoleEntry
| null>;

Defined in: packages/common/src/Console.ts:347

Latest entry written to this output.


write

readonly write: (entry: ConsoleEntry, formatter?: ConsoleFormatter) => void;

Defined in: packages/common/src/Console.ts:248

Write a log entry to this output.

Inherited from

ConsoleOutput.write