Blyp Docs

SolidStart

Import from @blyp/core/solid-start. The createLogger() export is an alias of createSolidStartLogger().

import { createMiddleware } from "@solidjs/start/middleware";
import { createLogger } from "@blyp/core/solid-start";

const solidLogger = createLogger({
  level: "info",
});

export default createMiddleware(solidLogger.middleware);

Accessing the logger

export async function GET(event: {
  locals: { blypLog?: { info: (message: string) => void } };
}) {
  event.locals.blypLog?.info("solidstart-route");
  return new Response("ok");
}
import { getRequestEvent } from "solid-js/web";

getRequestEvent()?.locals.blypLog?.info("solidstart-server");

Use event.locals.blypLog inside middleware and route handlers, and getRequestEvent()?.locals.blypLog elsewhere on the server when no event object is in scope.

Client ingestion route

// src/routes/inngest.ts
import { createLogger } from "@blyp/core/solid-start";

const solidLogger = createLogger();

export const POST = solidLogger.clientLogHandler;

The mounted route path must match clientLogging.path, otherwise Blyp returns a 500 mismatch response.

What auto-logged requests look like

With automatic request logging enabled, Blyp emits terminal output like:

[INFO]  GET  /health        200  2ms
[INFO]  POST /checkout      200  143ms
[INFO]  GET  /users/42      404  8ms
[ERROR] POST /payments      500  1203ms

Fields included automatically: method, path, status code, and duration.

In production (NDJSON):

{"level":"info","time":1710000000000,"msg":"GET /health","type":"http_request","method":"GET","url":"/health","statusCode":200,"responseTime":2}
{"level":"info","time":1710000000001,"msg":"POST /checkout","type":"http_request","method":"POST","url":"/checkout","statusCode":200,"responseTime":143}

Relevant types

import type {
  SolidStartLoggerConfig,
  SolidStartLoggerFactory,
  SolidStartFetchEvent,
  SolidStartAPIEvent,
  SolidStartLocals,
} from "@blyp/core/solid-start";