Creating a Custom Runtime with a Custom Logger in Effect

How do i use this way of creating a runtime and also replace the default Logger using const layer = Logger.replace(Logger.defaultLogger, Custom.logger)?

import { Runtime, FiberRefs } from "effect"
 
const testableRuntime = Runtime.make({
  context: Context.make(LoggingService, LoggingServiceLive).pipe(
    Context.add(EmailService, EmailServiceFake)
  ),
  fiberRefs: FiberRefs.empty(),
  runtimeFlags: Runtime.defaultRuntimeFlags
})


Not sure if i have the right expectation. I am thinking i can just plug the created runtime to any run* like this

const customRuntime = makeCustomRuntime()
Effect.runSync(customRuntime) 
//or
Effect.runPromise(customRuntime)
// or 

const CustomRuntime = makeCustomRuntime()

CustomRuntime.runPromise(program)

functions without doing this
Effect.runPromise(
  Effect.provide(Logger.withMinimumLogLevel(program, LogLevel.Debug), layer)
)


My last solution is to just create a function that sets all the layers including the custom logger and always pass it like this

pipe(
  Effect.provide(layerWithCustomLogger),
  Effect.runPromise,
)


The idea below seems neat though. Just not sure if possible.
const CustomRuntime = makeCustomRuntime()

CustomRuntime.runPromise(program)
Was this page helpful?