Hyperlinkv0.8.0-beta.28

Effect

Effect.logErrorconsteffect/Effect.ts:13870
(...message: ReadonlyArray<any>): Effect<void>

Logs one or more messages at the ERROR level.

Example (Logging errors)

import { Effect } from "effect"

const program = Effect.gen(function*() {
  yield* Effect.logError("Database connection failed")
  yield* Effect.logError(
    "Error code:",
    500,
    "Message:",
    "Internal server error"
  )

  // Can be used with error objects
  const error = new Error("Something went wrong")
  yield* Effect.logError("Caught error:", error.message)
})

Effect.runPromise(program)
// Output:
// timestamp=2023-... level=ERROR message="Database connection failed"
// timestamp=2023-... level=ERROR message="Error code: 500 Message: Internal server error"
// timestamp=2023-... level=ERROR message="Caught error: Something went wrong"
logging
export const logError: (...message: ReadonlyArray<any>) => Effect<void> = internal.logWithLevel("Error")
Referenced by 2 symbols