### Install functype-log Source: https://github.com/jordanburke/functype-log/blob/main/README.md Install the package and its peer dependency using pnpm. ```bash pnpm add functype-log functype ``` -------------------------------- ### Documentation: Pre-Checkin Command Source: https://github.com/jordanburke/functype-log/blob/main/STANDARDIZATION_GUIDE.md Example of documenting the main `ci` command for pre-checkin validation. ```bash pnpm run ci # 🚀 Main command: format, lint, test, and build everything ``` -------------------------------- ### Complete tsdown configuration example Source: https://github.com/jordanburke/functype-log/blob/main/MIGRATION_TSDOWN.md A full example of a tsdown.config.ts file for an ESM-only library. ```typescript import { defineConfig } from "tsdown" const env = process.env.NODE_ENV export default defineConfig({ entry: ["src/index.ts"], format: ["esm"], dts: true, clean: true, sourcemap: true, minify: env === "production", target: "es2020", outDir: env === "production" ? "dist" : "lib", outExtensions: () => ({ js: ".js", dts: ".d.ts", }), }) ``` -------------------------------- ### Quick Start with functype-log Source: https://github.com/jordanburke/functype-log/blob/main/README.md Initialize a program using the Logger service and provide the console layer. ```typescript import { IO } from "functype" import { Logger, LoggerLive } from "functype-log" const program = IO.gen(function* () { const log = yield* IO.service(Logger) yield* log.info("Starting", { version: "1.0.0" }) const result = yield* doWork() yield* log.info("Done", { result }) return result }) // Run with console logging await program.provideLayer(LoggerLive.console()).runOrThrow() ``` -------------------------------- ### Run tsdown migration Source: https://github.com/jordanburke/functype-log/blob/main/MIGRATION_TSDOWN.md Use the CLI to install tsdown and automatically migrate existing configurations. ```bash # Install tsdown and run automatic migration pnpm add -D tsdown npx tsdown migrate # Remove tsup pnpm remove tsup ``` -------------------------------- ### GitHub Actions Workflow Update (Before) Source: https://github.com/jordanburke/functype-log/blob/main/STANDARDIZATION_GUIDE.md Example of GitHub Actions workflow commands before standardization. ```yaml - run: pnpm install - run: pnpm run lint:format - run: pnpm run test - run: pnpm run build:prod ``` -------------------------------- ### withLogging Middleware Source: https://context7.com/jordanburke/functype-log/llms.txt Wraps an IO effect with start and completion logs at the debug level for tracing. ```APIDOC ## withLogging ### Description Wraps any IO effect with start/complete logging at debug level. Useful for tracing operation boundaries. ### Parameters - **name** (string) - Required - The name of the operation to log. - **effect** (IO) - Required - The IO effect to wrap. ### Request Example ```typescript const program = withLogging("fetchUsers", fetchUsers); ``` ``` -------------------------------- ### Testing with createTestLogger Source: https://github.com/jordanburke/functype-log/blob/main/CLAUDE.md Example of using `createTestLogger` to capture log entries in memory for testing purposes. Asserts the presence of a specific log entry. ```typescript const { logger, entries, hasEntry } = createTestLogger() await logger.info("test").runOrThrow() expect(hasEntry("info", "test")).toBe(true) ``` -------------------------------- ### Middleware withLogging Source: https://github.com/jordanburke/functype-log/blob/main/README.md Wraps an IO effect to log start and completion events at debug level. ```typescript import { withLogging } from "functype-log" const fetchUsers = Http.get("/api/users", { validate: UserSchema }) const logged = withLogging("fetchUsers", fetchUsers) // Logs: "fetchUsers: starting" then "fetchUsers: completed" ``` -------------------------------- ### Wrap IO Effect with Logging Middleware Source: https://context7.com/jordanburke/functype-log/llms.txt Adds debug-level logging for the start and completion of any IO effect. Useful for tracing the boundaries of operations. ```typescript import { IO } from "functype" import { Logger, withLogging, createTestLogger } from "functype-log" const fetchUsers = IO.succeed([{ id: 1, name: "Alice" }, { id: 2, name: "Bob" }]) const program = withLogging("fetchUsers", fetchUsers) const { logger, entries } = createTestLogger() const result = await program.provideService(Logger, logger).runOrThrow() console.log(result) // [{ id: 1, name: "Alice" }, { id: 2, name: "Bob" }] console.log(entries().toArray().map(e => e.message)) // ["fetchUsers: starting", "fetchUsers: completed"] ``` -------------------------------- ### Development Commands Source: https://github.com/jordanburke/functype-log/blob/main/CLAUDE.md Common development commands for formatting, linting, type checking, testing, and building the project. ```bash pnpm validate # Main: format → lint → typecheck → test → build (run before commits) pnpm test # Run all tests pnpm test -- test/logger.spec.ts # Run a single test file pnpm test -- -t "should attach metadata" # Run tests matching a pattern pnpm test:watch # Watch mode pnpm typecheck # TypeScript type check pnpm build # Production build (outputs to dist/) pnpm dev # Dev build with watch mode ``` -------------------------------- ### Documentation: Individual Commands Source: https://github.com/jordanburke/functype-log/blob/main/STANDARDIZATION_GUIDE.md Documentation for individual formatting, linting, testing, and building commands. ```bash # Formatting pnpm format # Format code with Prettier pnpm format:check # Check formatting without writing # Linting pnpm lint # Fix ESLint issues pnpm lint:check # Check ESLint issues without fixing # Testing pnpm test # Run tests once pnpm test:watch # Run tests in watch mode pnpm test:coverage # Run tests with coverage report # Building pnpm build # Production build pnpm dev # Development mode with watch ``` -------------------------------- ### Using Logger as IO Service Source: https://github.com/jordanburke/functype-log/blob/main/CLAUDE.md Demonstrates how to access and use the Logger service within an IO program. Requires providing the LoggerLive layer. ```typescript import { IO } from "functype" import { Logger, LoggerLive } from "functype-log" const program = IO.service(Logger).flatMap((log) => log.info("hello")) await program.provideLayer(LoggerLive.console()).runOrThrow() ``` -------------------------------- ### Validate migration Source: https://github.com/jordanburke/functype-log/blob/main/MIGRATION_TSDOWN.md Run validation and verify the expected output files. ```bash pnpm validate ``` ```text dist/index.js - ESM bundle dist/index.js.map - Source map dist/index.d.ts - Type declarations ``` -------------------------------- ### Configure output extensions Source: https://github.com/jordanburke/functype-log/blob/main/MIGRATION_TSDOWN.md Customize output file extensions to use .js instead of .mjs. ```typescript export default defineConfig({ format: ["esm"], outExtensions: () => ({ js: ".js", dts: ".d.ts", }), }) ``` -------------------------------- ### Use Logger Interface Source: https://context7.com/jordanburke/functype-log/llms.txt Demonstrates core logging methods, error context, persistent context, and child logger creation within an IO effect. ```typescript import { IO } from "functype" import { Logger, LoggerLive } from "functype-log" const program = IO.gen(function* () { const log = yield* IO.service(Logger) // Log levels yield* log.trace("verbose detail") yield* log.debug("debug info") yield* log.info("informational", { userId: "123" }) yield* log.warn("warning") yield* log.error("error occurred") yield* log.fatal("fatal error") // Error context const err = new Error("connection failed") yield* log.withError(err).error("operation failed") // Persistent context (included in all subsequent logs) const reqLog = log.withContext({ requestId: "req-1" }) yield* reqLog.info("first") // includes requestId yield* reqLog.info("second") // includes requestId // Child logger (inherits parent context) const child = reqLog.child({ handler: "users" }) yield* child.info("from child") // includes requestId + handler return "done" }) await program.provideLayer(LoggerLive.console()).runOrThrow() ``` -------------------------------- ### Standardized npm Scripts (After) Source: https://github.com/jordanburke/functype-log/blob/main/STANDARDIZATION_GUIDE.md This JSON object illustrates a standardized 'scripts' section in a package.json file after migration. It includes new scripts for CI, formatting checks, and improved build processes. ```json { "scripts": { "ci": "pnpm format && pnpm lint:check && pnpm test && pnpm build", "format": "prettier --write .", "format:check": "prettier --check .", "lint": "eslint ./src --fix", "lint:check": "eslint ./src", "test": "jest", "build": "rimraf dist && tsc && webpack", "dev": "webpack --watch", "prepublishOnly": "pnpm ci" } } ``` -------------------------------- ### Create and use a DirectTestLogger Source: https://context7.com/jordanburke/functype-log/llms.txt Initializes an in-memory logger for synchronous, imperative code testing. Use the returned handle to assert on log entries and convert existing IO loggers. ```typescript import { createDirectTestLogger, toDirectLogger, createTestLogger } from "functype-log" const { logger, entries, hasEntry, clear } = createDirectTestLogger() // Synchronous logging logger.info("user logged in", { userId: "u-123" }) logger.withContext({ session: "s-456" }).debug("session created") logger.withError(new Error("timeout")).error("request failed") // Assert on entries console.log(entries().size) // 3 console.log(hasEntry("info", "logged in")) // true console.log(hasEntry("error", /timeout/)) // false (message is "request failed") const errorEntry = entries().toArray().find(e => e.level === "error") console.log(errorEntry?.error?.message) // "timeout" // Convert IO Logger to DirectLogger const ioHandle = createTestLogger() const direct = toDirectLogger(ioHandle.logger) direct.info("via conversion") console.log(ioHandle.hasEntry("info", "via conversion")) // true ``` -------------------------------- ### Configure OpenTelemetry Plugin Source: https://github.com/jordanburke/functype-log/blob/main/README.md Add OpenTelemetry support via LogLayer plugins. ```typescript import { openTelemetryPlugin } from "@loglayer/plugin-opentelemetry" const otelLog = new LogLayer({ transport: new PinoTransport({ logger: pino() }), plugins: [openTelemetryPlugin()], }) await program.provideLayer(LoggerLive.fromLogLayer(otelLog)).runOrThrow() ``` -------------------------------- ### Configure Console Logging Source: https://github.com/jordanburke/functype-log/blob/main/README.md Apply the console layer with optional configuration. ```typescript await program.provideLayer(LoggerLive.console()).runOrThrow() await program.provideLayer(LoggerLive.console({ prefix: "[APP]" })).runOrThrow() ``` -------------------------------- ### Inconsistent npm Scripts (Before) Source: https://github.com/jordanburke/functype-log/blob/main/STANDARDIZATION_GUIDE.md This JSON object shows a typical 'scripts' section in a package.json file before standardization. It includes common build, test, and linting commands. ```json { "scripts": { "build": "tsc && webpack", "test": "jest", "lint:format": "prettier --write .", "lint:fix": "eslint --fix src", "prepublishOnly": "npm run build" } } ``` -------------------------------- ### Configure LogLayer Transport Source: https://github.com/jordanburke/functype-log/blob/main/README.md Integrate LogLayer transports like Pino for production logging. ```typescript import { LogLayer } from "loglayer" import { PinoTransport } from "@loglayer/transport-pino" import pino from "pino" const pinoLog = new LogLayer({ transport: new PinoTransport({ logger: pino() }), }) await program.provideLayer(LoggerLive.fromLogLayer(pinoLog)).runOrThrow() ``` -------------------------------- ### Subpath Exports Source: https://context7.com/jordanburke/functype-log/llms.txt Granular imports for tree-shaking and explicit dependency management. ```APIDOC ## Subpath Exports ### Description The library provides specific subpath exports to allow for smaller bundle sizes and clearer dependency management. ### Available Modules - `functype-log/logger`: Core types and interfaces. - `functype-log/layers`: Layer constructors (e.g., LoggerLive, createConsoleLogger). - `functype-log/testing`: Test utilities. - `functype-log/middleware`: Middleware utilities (e.g., withLogging). - `functype-log/direct`: Imperative/Direct logging utilities. - `functype-log/adapter`: LogLayer adapters. ``` -------------------------------- ### Logger API Usage Source: https://github.com/jordanburke/functype-log/blob/main/README.md Demonstrates various logging levels, structured metadata, error context, and child loggers. ```typescript const log = yield * IO.service(Logger) // Log levels yield * log.trace("verbose detail") yield * log.debug("debug info") yield * log.info("informational") yield * log.warn("warning") yield * log.error("error occurred") yield * log.fatal("fatal error") // Structured metadata yield * log.info("user action", { userId: "123", action: "login" }) // Error context yield * log.withError(err).error("operation failed") // Persistent context const reqLog = log.withContext({ requestId: "req-1" }) yield * reqLog.info("first") // includes requestId yield * reqLog.info("second") // includes requestId // Child logger const child = log.child({ handler: "users" }) ``` -------------------------------- ### Module Structure Source: https://github.com/jordanburke/functype-log/blob/main/CLAUDE.md Overview of the project's module structure, indicating the purpose of each directory. ```tree src/ logger/ # Logger interface, Tag, LogLevel, LogMetadata, LogEntry types adapter/ # LogLayerAdapter: ILogLayer → Logger bridge (internal) layers/ # LoggerLive factory: console(), silent(), fromLogLayer() testing/ # TestLogger: captures entries as List middleware/ # withLogging, tapLog utilities ``` -------------------------------- ### Configure package.json module type Source: https://github.com/jordanburke/functype-log/blob/main/MIGRATION_TSDOWN.md Set the package type to module for ESM support. ```json { "type": "module" } ``` -------------------------------- ### createDirectTestLogger Source: https://context7.com/jordanburke/functype-log/llms.txt Creates an in-memory test logger with the DirectLogger (synchronous) interface for imperative code testing. ```APIDOC ## createDirectTestLogger ### Description Creates an in-memory test logger with the DirectLogger (synchronous) interface. Provides assertion capabilities for imperative code. ### Usage ```typescript const { logger, entries, hasEntry, clear } = createDirectTestLogger(); // Synchronous logging logger.info("message", { metadata: "value" }); // Assert on entries const count = entries().size; const exists = hasEntry("info", "message"); ``` ``` -------------------------------- ### Configure Console Logger Source: https://context7.com/jordanburke/functype-log/llms.txt Initializes a console logger layer for development, supporting optional prefixes. ```typescript import { IO } from "functype" import { Logger, LoggerLive } from "functype-log" const program = IO.gen(function* () { const log = yield* IO.service(Logger) yield* log.info("Starting application", { version: "1.0.0" }) yield* log.debug("Configuration loaded") return "started" }) // Basic console logging await program.provideLayer(LoggerLive.console()).runOrThrow() // With prefix for identifying log source await program.provideLayer(LoggerLive.console({ prefix: "[APP]" })).runOrThrow() // Output: [APP] Starting application { version: "1.0.0" } ``` -------------------------------- ### Update package.json build scripts Source: https://github.com/jordanburke/functype-log/blob/main/MIGRATION_TSDOWN.md Update build and watch scripts to use tsdown. ```json { "scripts": { "build": "rimraf dist && cross-env NODE_ENV=production tsdown", "build:watch": "tsdown --watch", "dev": "tsdown --watch" } } ``` -------------------------------- ### DirectLogger Source: https://context7.com/jordanburke/functype-log/llms.txt Provides an imperative, synchronous logging interface that wraps the IO-based Logger. ```APIDOC ## DirectLogger ### Description Imperative/synchronous logging interface that wraps the IO-based Logger. Useful when you need immediate logging without effect composition. ### Methods - **createDirectConsoleLogger(options)** - Creates a console-based direct logger. - **createDirectTestLogger()** - Creates a test-based direct logger. - **directSilentLogger** - A logger that performs no operations. ``` -------------------------------- ### Create Direct Console Logger Source: https://context7.com/jordanburke/functype-log/llms.txt Provides an imperative, synchronous logging interface that wraps the IO-based Logger. Suitable for immediate logging without effect composition. ```typescript import { createDirectConsoleLogger, createDirectTestLogger, directSilentLogger } from "functype-log" // Create direct console logger const log = createDirectConsoleLogger({ prefix: "[APP]" }) // Synchronous logging (no IO, no await) log.info("Application starting", { pid: process.pid }) log.debug("Config loaded") log.warn("Deprecated API used") // Error context const err = new Error("connection refused") log.withError(err).error("Database connection failed") // Persistent context const reqLog = log.withContext({ requestId: "req-123" }) reqLog.info("Processing request") reqLog.debug("Fetching user data") // Child loggers const child = reqLog.child({ handler: "users" }) child.info("User found") // includes requestId + handler // Direct silent logger for tests directSilentLogger.info("This goes nowhere") ``` -------------------------------- ### GitHub Actions Workflow Update (After) Source: https://github.com/jordanburke/functype-log/blob/main/STANDARDIZATION_GUIDE.md Updated GitHub Actions workflow commands using the standardized `ci` command. ```yaml - run: pnpm install - run: pnpm run ci ``` -------------------------------- ### logLayerAdapter Source: https://context7.com/jordanburke/functype-log/llms.txt Converts an ILogLayer instance into a functype-log Logger, allowing integration with existing LogLayer configurations. ```APIDOC ## logLayerAdapter ### Description Converts an ILogLayer instance to a functype-log Logger. This is primarily used internally by LoggerLive but is exposed for advanced use cases. ### Parameters - **logLayer** (ILogLayer) - Required - The LogLayer instance to adapt. ### Request Example ```typescript const logLayer = new LogLayer({ transport: new ConsoleTransport({ logger: console }) }); const logger = logLayerAdapter(logLayer); ``` ``` -------------------------------- ### createTestLogger Source: https://context7.com/jordanburke/functype-log/llms.txt Creates an in-memory logger for capturing and asserting log entries in tests. ```APIDOC ## createTestLogger ### Description Creates an in-memory test logger that captures all log entries for assertions. Returns a handle with the logger instance, entries accessor, clear function, and hasEntry matcher. ### Response - **logger** (Logger) - The logger instance. - **entries** (Function) - Accessor for captured log entries. - **hasEntry** (Function) - Matcher function to check for specific logs. - **clear** (Function) - Clears captured entries. ``` -------------------------------- ### Import modules via subpath exports Source: https://context7.com/jordanburke/functype-log/llms.txt Utilize subpath exports for granular dependency management and improved tree-shaking. ```typescript // Everything (main entry) import { Logger, LoggerLive, createTestLogger, withLogging } from "functype-log" // Types only import { Logger } from "functype-log/logger" import type { LogEntry, LogLevel, LogMetadata } from "functype-log/logger" // Layer constructors only import { LoggerLive, createConsoleLogger, silentLogger } from "functype-log/layers" import type { ConsoleLoggerOptions } from "functype-log/layers" // Test utilities only import { createTestLogger } from "functype-log/testing" import type { TestLoggerHandle } from "functype-log/testing" // Middleware only import { withLogging, tapLog } from "functype-log/middleware" // Direct/imperative logging import { createDirectConsoleLogger, createDirectTestLogger, toDirectLogger, directSilentLogger } from "functype-log/direct" import type { DirectLogger, DirectTestLoggerHandle } from "functype-log/direct" // Adapter (advanced) import { logLayerAdapter } from "functype-log/adapter" ``` -------------------------------- ### tapLog Middleware Source: https://context7.com/jordanburke/functype-log/llms.txt Creates a tap function that logs after an effect completes, supporting static or dynamic messages. ```APIDOC ## tapLog ### Description Creates a tap function that logs after an effect completes. Supports both static messages and message functions that receive the result. ### Parameters - **level** (string) - Required - The log level (e.g., "info", "debug"). - **message** (string | (result) => string) - Required - The message to log. ### Request Example ```typescript const program = tapLog("info", (arr) => `fetched ${arr.length} items`)(fetchItems); ``` ``` -------------------------------- ### Create In-Memory Test Logger Source: https://context7.com/jordanburke/functype-log/llms.txt Generates an in-memory logger for testing that captures all log entries. Provides accessors for entries, a clear function, and an entry matcher. ```typescript import { IO } from "functype" import { Logger, createTestLogger } from "functype-log" const { logger, entries, hasEntry, clear } = createTestLogger() // Run program with test logger const program = IO.gen(function* () { const log = yield* IO.service(Logger) yield* log.info("Starting", { version: "1.0.0" }) yield* log.warn("Low memory") yield* log.error("Connection failed") return "done" }) await program.provideService(Logger, logger).runOrThrow() // Assert on captured entries console.log(entries().size) // 3 // Check for specific entries console.log(hasEntry("info", "Starting")) // true console.log(hasEntry("error", "Connection failed")) // true console.log(hasEntry("info", /version/)) // true (regex match) console.log(hasEntry("debug", "anything")) // false // Access full entry details const first = entries().head console.log(first.level) // "info" console.log(first.message) // "Starting" console.log(first.metadata) // { version: "1.0.0" } console.log(first.timestamp) // Date instance // Clear entries between tests clear() console.log(entries().size) // 0 ``` -------------------------------- ### Testing with createTestLogger Source: https://github.com/jordanburke/functype-log/blob/main/README.md Captures log entries in memory to perform assertions in tests. ```typescript import { createTestLogger } from "functype-log" const { logger, entries, hasEntry, clear } = createTestLogger() await myProgram.provideService(Logger, logger).runOrThrow() // Assert on captured entries expect(entries().size).toBe(2) expect(hasEntry("info", "Starting")).toBe(true) expect(hasEntry("info", /fetched \d+ items/)).toBe(true) // Entries are List with full metadata const first = entries().head expect(first.level).toBe("info") expect(first.metadata).toEqual({ version: "1.0.0" }) expect(first.timestamp).toBeInstanceOf(Date) ``` -------------------------------- ### Integrate Custom LogLayer Transports Source: https://context7.com/jordanburke/functype-log/llms.txt Wraps existing LogLayer instances to support production transports like Pino or OpenTelemetry. ```typescript import { IO } from "functype" import { LogLayer } from "loglayer" import { PinoTransport } from "@loglayer/transport-pino" import pino from "pino" import { Logger, LoggerLive } from "functype-log" // Create a pino-backed LogLayer const pinoLog = new LogLayer({ transport: new PinoTransport({ logger: pino() }), }) const program = IO.gen(function* () { const log = yield* IO.service(Logger) yield* log.info("Production log via pino", { env: "production" }) return "success" }) await program.provideLayer(LoggerLive.fromLogLayer(pinoLog)).runOrThrow() // With OpenTelemetry plugin import { openTelemetryPlugin } from "@loglayer/plugin-opentelemetry" const otelLog = new LogLayer({ transport: new PinoTransport({ logger: pino() }), plugins: [openTelemetryPlugin()], }) await program.provideLayer(LoggerLive.fromLogLayer(otelLog)).runOrThrow() ``` -------------------------------- ### Update package.json exports Source: https://github.com/jordanburke/functype-log/blob/main/MIGRATION_TSDOWN.md Configure exports for ESM-only or dual ESM/CJS builds. ```json { "main": "./dist/index.js", "types": "./dist/index.d.ts", "exports": { ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" } } } ``` ```json { "main": "./dist/index.cjs", "module": "./dist/index.mjs", "types": "./dist/index.d.mts", "exports": { ".": { "types": { "import": "./dist/index.d.mts", "require": "./dist/index.d.cts" }, "import": "./dist/index.mjs", "require": "./dist/index.cjs" } } } ``` -------------------------------- ### Tap and Log IO Effect Completion Source: https://context7.com/jordanburke/functype-log/llms.txt Creates a tap function that logs after an effect finishes. Supports static messages or dynamic messages based on the result. ```typescript import { IO } from "functype" import { Logger, tapLog, createTestLogger } from "functype-log" const fetchItems = IO.succeed([1, 2, 3, 4, 5]) // Static message const program1 = tapLog("info", "items fetched")(fetchItems) // Dynamic message based on result const program2 = tapLog( "info", (arr) => `fetched ${arr.length} items` )(fetchItems) const { logger, entries } = createTestLogger() const result = await program2.provideService(Logger, logger).runOrThrow() console.log(result) // [1, 2, 3, 4, 5] console.log(entries().head.message) // "fetched 5 items" console.log(entries().head.level) // "info" ``` -------------------------------- ### Middleware tapLog Source: https://github.com/jordanburke/functype-log/blob/main/README.md Logs a message after an effect completes successfully. ```typescript import { tapLog } from "functype-log" const result = await tapLog( "info", (arr) => `fetched ${arr.length} items`, )(IO.succeed([1, 2, 3])) .provideService(Logger, logger) .runOrThrow() ``` -------------------------------- ### Standardized package.json Scripts Source: https://github.com/jordanburke/functype-log/blob/main/STANDARDIZATION_GUIDE.md Defines standardized npm/pnpm scripts for a TypeScript project, including CI, formatting, linting, testing, and building. ```json "scripts": { "ci": "pnpm format && pnpm lint:check && pnpm test && pnpm build", "format": "prettier --write .", "format:check": "prettier --check .", "lint": "eslint ./src --fix", "lint:check": "eslint ./src", "test": "vitest run", "test:watch": "vitest", "test:coverage": "vitest run --coverage", "test:ui": "vitest --ui", "build": "rimraf dist && cross-env NODE_ENV=production tsdown", "build:watch": "tsdown --watch", "dev": "tsdown --watch", "prepublishOnly": "pnpm ci", "ts-types": "tsc --noEmit" } ``` -------------------------------- ### Configure Silent Logging Source: https://github.com/jordanburke/functype-log/blob/main/README.md Use the silent layer for testing or suppressing output. ```typescript await program.provideLayer(LoggerLive.silent()).runOrThrow() ``` -------------------------------- ### Adapt ILogLayer to functype-log Logger Source: https://context7.com/jordanburke/functype-log/llms.txt Converts an ILogLayer instance to a functype-log Logger. Primarily for internal use by LoggerLive but available for advanced scenarios. ```typescript import { LogLayer, ConsoleTransport } from "loglayer" import { logLayerAdapter } from "functype-log" const logLayer = new LogLayer({ transport: new ConsoleTransport({ logger: console }), prefix: "[CUSTOM]", }) const logger = logLayerAdapter(logLayer) // Use directly (returns IO effects) await logger.info("custom message", { key: "value" }).runOrThrow() await logger.withContext({ service: "api" }).debug("with context").runOrThrow() ``` -------------------------------- ### Configure Silent Logger Source: https://context7.com/jordanburke/functype-log/llms.txt Uses a no-op logger to suppress output, useful for testing environments. ```typescript import { IO } from "functype" import { Logger, LoggerLive, silentLogger } from "functype-log" const program = IO.gen(function* () { const log = yield* IO.service(Logger) yield* log.info("This won't appear anywhere") return 42 }) // Run with silent logging (no output) const result = await program.provideLayer(LoggerLive.silent()).runOrThrow() console.log(result) // 42 // silentLogger always returns itself for withContext/withError/child const contextLogger = silentLogger.withContext({ key: "value" }) console.log(contextLogger === silentLogger) // true ``` -------------------------------- ### Subpath Exports Source: https://github.com/jordanburke/functype-log/blob/main/README.md Import specific modules from the package subpaths. ```typescript import { Logger } from "functype-log" // everything import { Logger } from "functype-log/logger" // types only import { LoggerLive } from "functype-log/layers" // layer constructors import { createTestLogger } from "functype-log/testing" // test utilities import { withLogging } from "functype-log/middleware" // middleware ``` -------------------------------- ### Update tsdown configuration Source: https://github.com/jordanburke/functype-log/blob/main/MIGRATION_TSDOWN.md Replace the tsup export style with the tsdown defineConfig function. ```typescript // Before (tsup style) import type { Options } from "tsup" export const tsup: Options = { ... } // After (tsdown style) import { defineConfig } from "tsdown" export default defineConfig({ ... }) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.