1import * as Logger from "effect/Logger";
2import { ANSI_RESET, colorsEnabled } from "./Terminal.ts";
3
4/** Effect pretty prefixes with selective color and untouched message styling. */
5export const makePlainConsoleSink = (colors = colorsEnabled()) => {
6 const pretty = Logger.consolePretty({ colors });
7 if (!colors) return pretty;
8 return Logger.make<unknown, void>((options) => {
9 const messages = Array.isArray(options.message)
10 ? options.message
11 : [options.message];
12 pretty.log({
13 ...options,
14 // consolePretty applies bold cyan around the first string. Reset that
15 // wrapper before the content; any intentional ANSI inside the message
16 // still takes effect normally.
17 message: [
18 `${ANSI_RESET}${String(messages[0] ?? "")}`,
19 ...messages.slice(1),
20 ],
21 });
22 });
23};