Skip to main content
ff-serv provides a Logger namespace with Effect-based logging functions and a synchronous logger for non-Effect code.

Usage

Effect Logging

Use Logger.info, Logger.debug, Logger.warn, and Logger.error in Effect code:

Log with Attributes

Pass an object as the first argument to add structured attributes:
Output:

Log without Attributes

Pass only a message string:

Synchronous Logger

For logging outside of Effect code (e.g., in callbacks or external libraries), use Logger.sync():

With Initial Annotations

Create a logger with persistent annotations:

Child Loggers

Create child loggers with additional annotations:
Parent loggers are unaffected by child creation:

Per-Call Attributes

Add attributes to individual log calls:

API Reference

Effect Logging Functions

Synchronous Logger

Complete Example

Integration with createFetchHandler

createFetchHandler automatically logs:
  • Request start: Pathname and request ID
  • Request end: Status code (info for 2xx/3xx, warn for others)
  • Errors: Unhandled exceptions with full cause
All logs include a unique requestId annotation. Example output:

Customizing Log Output

Logger uses Effect’s built-in logging system. Customize with Effect’s logger layers:
See Effect’s Logger documentation for more options.