(name?: string): Config<LogLevel_.LogLevel>Creates a config for a log level string.
When to use
Use to read Effect log-level settings from configuration.
Details
Shortcut for Config.schema(Config.LogLevel, name).
Accepted values: "All", "Fatal", "Error", "Warn", "Info",
"Debug", "Trace", "None".
Example (Reading a log level)
import { Config, ConfigProvider, Effect } from "effect"
const program = Effect.gen(function*() {
const logLevel = yield* Config.logLevel("LOG_LEVEL")
console.log(logLevel)
})
const provider = ConfigProvider.fromEnv({
env: {
LOG_LEVEL: "Info"
}
})
Effect.runSync(
program.pipe(Effect.provideService(ConfigProvider.ConfigProvider, provider))
)
// Output: "Info"export function function logLevel(
name?: string
): Config<LogLevel_.LogLevel>
Creates a config for a log level string.
When to use
Use to read Effect log-level settings from configuration.
Details
Shortcut for Config.schema(Config.LogLevel, name).
Accepted values: "All", "Fatal", "Error", "Warn", "Info",
"Debug", "Trace", "None".
Example (Reading a log level)
import { Config, ConfigProvider, Effect } from "effect"
const program = Effect.gen(function*() {
const logLevel = yield* Config.logLevel("LOG_LEVEL")
console.log(logLevel)
})
const provider = ConfigProvider.fromEnv({
env: {
LOG_LEVEL: "Info"
}
})
Effect.runSync(
program.pipe(Effect.provideService(ConfigProvider.ConfigProvider, provider))
)
// Output: "Info"
logLevel(name: string | undefinedname?: string) {
return function schema<T>(
codec: Schema.ConstraintCodec<T, unknown>,
path?: string | ConfigProvider.Path
): Config<T>
Creates a Config<T> from a Schema.Codec.
When to use
Use when you need to read structured or schema-validated configuration.
Details
The optional path sets the local path segment(s) for the config lookup.
It is appended to the logical path prefix accumulated from outer
nested
calls. Pass a single string for a flat key or an array for
nested paths.
Convenience constructors such as string, number, and boolean delegate
to this API.
The codec is used to decode the raw StringTree produced by the provider
into T. Schema validation errors are wrapped in ConfigError.
Example (Reading a structured config)
import { Config, ConfigProvider, Effect, Schema } from "effect"
const DbConfig = Config.schema(
Schema.Struct({
host: Schema.String,
port: Schema.Int
}),
"db"
)
const provider = ConfigProvider.fromUnknown({
db: { host: "localhost", port: 5432 }
})
// Effect.runSync(DbConfig.parse(provider))
// { host: "localhost", port: 5432 }
schema(const LogLevel: Schema.Literals<
ReadonlyArray<LogLevel_.LogLevel>
>
const LogLevel: {
literals: L;
members: { readonly [K in keyof L]: Literal<L[K]>; };
mapMembers: (f: (members: ReadonlyArray<Schema.Literal<LogLevel_.LogLevel>>) => To) => Schema.Union<{ [K in keyof Readonly<To>]: Readonly<To>[K]; }>;
pick: (literals: L2) => Schema.Literals<L2>;
transform: (to: L2) => Schema.Union<ReadonlyArray<Schema.decodeTo<Schema.Literal<L2[number]>, Schema.Literal<LogLevel_.LogLevel>, never, never>>>;
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<LogLevel_.LogLevel, readonly []>) => Schema.Literals<ReadonlyArray<LogLevel_.LogLevel>>;
annotateKey: (annotations: Schema.Annotations.Key<LogLevel_.LogLevel>) => Schema.Literals<ReadonlyArray<LogLevel_.LogLevel>>;
check: (checks_0: SchemaAST.Check<LogLevel_.LogLevel>, ...checks: Array<SchemaAST.Check<LogLevel_.LogLevel>>) => Schema.Literals<ReadonlyArray<LogLevel_.LogLevel>>;
rebuild: (ast: SchemaAST.Union<SchemaAST.Literal>) => Schema.Literals<ReadonlyArray<LogLevel_.LogLevel>>;
make: (input: LogLevel, options?: MakeOptions) => LogLevel;
makeOption: (input: LogLevel, options?: MakeOptions) => Option_.Option<LogLevel>;
makeEffect: (input: LogLevel, options?: MakeOptions) => Effect.Effect<LogLevel, SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
Schema for LogLevel string literals.
When to use
Use when you need the reusable log-level schema value for Config.schema
with custom paths.
Details
Accepted values: "All", "Fatal", "Error", "Warn", "Info",
"Debug", "Trace", "None".
LogLevel, name: string | undefinedname)
}