Unexpected extra error message
With the following code, I'm getting an unexpected extra error message:
import * as Schema from '@effect/schema/Schema';
import { Config, ConfigError, Effect, Either, Layer, Logger } from 'effect';
export const logger = Logger.make(a => {
globalThis.console.log(JSON.stringify(a));
});
const DebugOutputFormat = Schema.literal('JSON', 'Readable');
type DebugOutputFormat = Schema.Schema.To<typeof DebugOutputFormat>;
const debugOutputFormat = (name: string): Config.Config<DebugOutputFormat> => {
const config = Config.mapOrFail(Config.string(), value => {
return Schema.parseEither(DebugOutputFormat)(value).pipe(
Either.mapLeft(() =>
ConfigError.InvalidData(
[],
`Expected a debug output format of 'JSON' or 'Readable', but found: ${value}`,
),
),
);
});
return Config.nested(config, name);
};
export const LoggerLive = Layer.merge(
Effect.config(Config.logLevel('DEBUG_LEVEL')).pipe(
Effect.map(level => Logger.minimumLogLevel(level)),
Layer.unwrapEffect,
),
Effect.config(debugOutputFormat('DEBUG_OUTPUT_FORMAT')).pipe(
Effect.map(format =>
Logger.replace(Logger.defaultLogger, format === 'Readable' ? Logger.defaultLogger : logger),
),
Layer.unwrapEffect,
),
);import * as Schema from '@effect/schema/Schema';
import { Config, ConfigError, Effect, Either, Layer, Logger } from 'effect';
export const logger = Logger.make(a => {
globalThis.console.log(JSON.stringify(a));
});
const DebugOutputFormat = Schema.literal('JSON', 'Readable');
type DebugOutputFormat = Schema.Schema.To<typeof DebugOutputFormat>;
const debugOutputFormat = (name: string): Config.Config<DebugOutputFormat> => {
const config = Config.mapOrFail(Config.string(), value => {
return Schema.parseEither(DebugOutputFormat)(value).pipe(
Either.mapLeft(() =>
ConfigError.InvalidData(
[],
`Expected a debug output format of 'JSON' or 'Readable', but found: ${value}`,
),
),
);
});
return Config.nested(config, name);
};
export const LoggerLive = Layer.merge(
Effect.config(Config.logLevel('DEBUG_LEVEL')).pipe(
Effect.map(level => Logger.minimumLogLevel(level)),
Layer.unwrapEffect,
),
Effect.config(debugOutputFormat('DEBUG_OUTPUT_FORMAT')).pipe(
Effect.map(format =>
Logger.replace(Logger.defaultLogger, format === 'Readable' ? Logger.defaultLogger : logger),
),
Layer.unwrapEffect,
),
);