Logger overview
Added in v2.0.0
Table of contents
console
withConsoleError
Signature
export declare const withConsoleError: <M, O>(self: Logger<M, O>) => Logger<M, void>
Added in v2.0.0
withConsoleLog
Signature
export declare const withConsoleLog: <M, O>(self: Logger<M, O>) => Logger<M, void>
Added in v2.0.0
constructors
defaultLogger
Signature
export declare const defaultLogger: Logger<unknown, void>
Added in v2.0.0
json
Signature
export declare const json: Layer.Layer<never, never, never>
Added in v2.0.0
jsonLogger
Signature
export declare const jsonLogger: Logger<unknown, string>
Added in v2.0.0
logFmt
Signature
export declare const logFmt: Layer.Layer<never, never, never>
Added in v2.0.0
logfmtLogger
Signature
export declare const logfmtLogger: Logger<unknown, string>
Added in v2.0.0
make
Signature
export declare const make: <Message, Output>(
log: (options: Logger.Options<Message>) => Output
) => Logger<Message, Output>
Added in v2.0.0
none
A logger that does nothing in response to logging events.
Signature
export declare const none: Logger<unknown, void>
Added in v2.0.0
simple
Signature
export declare const simple: <A, B>(log: (a: A) => B) => Logger<A, B>
Added in v2.0.0
stringLogger
Signature
export declare const stringLogger: Logger<unknown, string>
Added in v2.0.0
structured
Signature
export declare const structured: Layer.Layer<never, never, never>
Added in v2.0.0
structuredLogger
Signature
export declare const structuredLogger: Logger<
unknown,
{
readonly logLevel: string
readonly fiberId: string
readonly timestamp: string
readonly message: unknown
readonly cause: string | undefined
readonly annotations: Record<string, unknown>
readonly spans: Record<string, number>
}
>
Added in v2.0.0
succeed
Signature
export declare const succeed: <A>(value: A) => Logger<unknown, A>
Added in v2.0.0
sync
Signature
export declare const sync: <A>(evaluate: LazyArg<A>) => Logger<unknown, A>
Added in v2.0.0
test
Signature
export declare const test: {
<Message>(input: Message): <Output>(self: Logger<Message, Output>) => Output
<Message, Output>(self: Logger<Message, Output>, input: Message): Output
}
Added in v2.0.0
tracerLogger
Signature
export declare const tracerLogger: Logger<unknown, void>
Added in v2.0.0
context
add
Signature
export declare const add: <B>(logger: Logger<unknown, B>) => Layer.Layer<never>
Added in v2.0.0
addEffect
Signature
export declare const addEffect: <A, E, R>(effect: Effect<Logger<unknown, A>, E, R>) => Layer.Layer<never, E, R>
Added in v2.0.0
addScoped
Signature
export declare const addScoped: <A, E, R>(
effect: Effect<Logger<unknown, A>, E, R>
) => Layer.Layer<never, E, Exclude<R, Scope>>
Added in v2.0.0
minimumLogLevel
Signature
export declare const minimumLogLevel: (level: LogLevel.LogLevel) => Layer.Layer<never>
Added in v2.0.0
remove
Signature
export declare const remove: <A>(logger: Logger<unknown, A>) => Layer.Layer<never>
Added in v2.0.0
replace
Signature
export declare const replace: {
<B>(that: Logger<unknown, B>): <A>(self: Logger<unknown, A>) => Layer.Layer<never>
<A, B>(self: Logger<unknown, A>, that: Logger<unknown, B>): Layer.Layer<never>
}
Added in v2.0.0
replaceEffect
Signature
export declare const replaceEffect: {
<B, E, R>(that: Effect<Logger<unknown, B>, E, R>): <A>(self: Logger<unknown, A>) => Layer.Layer<never, E, R>
<A, B, E, R>(self: Logger<unknown, A>, that: Effect<Logger<unknown, B>, E, R>): Layer.Layer<never, E, R>
}
Added in v2.0.0
replaceScoped
Signature
export declare const replaceScoped: {
<B, E, R>(
that: Effect<Logger<unknown, B>, E, R>
): <A>(self: Logger<unknown, A>) => Layer.Layer<never, E, Exclude<R, Scope>>
<A, B, E, R>(
self: Logger<unknown, A>,
that: Effect<Logger<unknown, B>, E, R>
): Layer.Layer<never, E, Exclude<R, Scope>>
}
Added in v2.0.0
withMinimumLogLevel
Signature
export declare const withMinimumLogLevel: {
(level: LogLevel.LogLevel): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, R>
<A, E, R>(self: Effect<A, E, R>, level: LogLevel.LogLevel): Effect<A, E, R>
}
Added in v2.0.0
filtering
filterLogLevel
Returns a version of this logger that only logs messages when the log level satisfies the specified predicate.
Signature
export declare const filterLogLevel: {
(
f: (logLevel: LogLevel.LogLevel) => boolean
): <Message, Output>(self: Logger<Message, Output>) => Logger<Message, Option.Option<Output>>
<Message, Output>(
self: Logger<Message, Output>,
f: (logLevel: LogLevel.LogLevel) => boolean
): Logger<Message, Option.Option<Output>>
}
Added in v2.0.0
guards
isLogger
Returns true
if the specified value is a Logger
, otherwise returns false
.
Signature
export declare const isLogger: (u: unknown) => u is Logger<unknown, unknown>
Added in v1.0.0
mapping
batched
Signature
export declare const batched: {
<Output, R>(
window: DurationInput,
f: (messages: Types.NoInfer<Output>[]) => Effect<void, never, R>
): <Message>(self: Logger<Message, Output>) => Effect<Logger<Message, void>, never, Scope | R>
<Message, Output, R>(
self: Logger<Message, Output>,
window: DurationInput,
f: (messages: Types.NoInfer<Output>[]) => Effect<void, never, R>
): Effect<Logger<Message, void>, never, Scope | R>
}
Example
import { Console, Effect, Logger } from "effect"
const LoggerLive = Logger.replaceScoped(
Logger.defaultLogger,
Logger.logfmtLogger.pipe(Logger.batched("500 millis", (messages) => Console.log("BATCH", messages.join("\n"))))
)
Effect.gen(function* (_) {
yield* _(Effect.log("one"))
yield* _(Effect.log("two"))
yield* _(Effect.log("three"))
}).pipe(Effect.provide(LoggerLive), Effect.runFork)
Added in v2.0.0
map
Signature
export declare const map: {
<Output, Output2>(
f: (output: Output) => Output2
): <Message>(self: Logger<Message, Output>) => Logger<Message, Output2>
<Message, Output, Output2>(self: Logger<Message, Output>, f: (output: Output) => Output2): Logger<Message, Output2>
}
Added in v2.0.0
mapInput
Signature
export declare const mapInput: {
<Message, Message2>(
f: (message: Message2) => Message
): <Output>(self: Logger<Message, Output>) => Logger<Message2, Output>
<Output, Message, Message2>(
self: Logger<Message, Output>,
f: (message: Message2) => Message
): Logger<Message2, Output>
}
Added in v2.0.0
mapInputOptions
Signature
export declare const mapInputOptions: {
<Message, Message2>(
f: (options: Logger.Options<Message2>) => Logger.Options<Message>
): <Output>(self: Logger<Message, Output>) => Logger<Message2, Output>
<Output, Message, Message2>(
self: Logger<Message, Output>,
f: (options: Logger.Options<Message2>) => Logger.Options<Message>
): Logger<Message2, Output>
}
Added in v2.0.0
models
Logger (interface)
Signature
export interface Logger<in Message, out Output> extends Logger.Variance<Message, Output>, Pipeable {
log(options: Logger.Options<Message>): Output
}
Added in v2.0.0
symbols
LoggerTypeId
Signature
export declare const LoggerTypeId: typeof LoggerTypeId
Added in v2.0.0
LoggerTypeId (type alias)
Signature
export type LoggerTypeId = typeof LoggerTypeId
Added in v2.0.0
tracing
withSpanAnnotations
Signature
export declare const withSpanAnnotations: <Message, Output>(self: Logger<Message, Output>) => Logger<Message, Output>
Added in v2.0.0
utils
Logger (namespace)
Added in v2.0.0
Options (interface)
Signature
export interface Options<out Message> {
readonly fiberId: FiberId.FiberId
readonly logLevel: LogLevel.LogLevel
readonly message: Message
readonly cause: Cause.Cause<unknown>
readonly context: FiberRefs.FiberRefs
readonly spans: List.List<LogSpan.LogSpan>
readonly annotations: HashMap.HashMap<string, unknown>
readonly date: Date
}
Added in v2.0.0
Variance (interface)
Signature
export interface Variance<in Message, out Output> {
readonly [LoggerTypeId]: {
readonly _Message: Types.Contravariant<Message>
readonly _Output: Types.Covariant<Output>
}
}
Added in v2.0.0
zipping
zip
Combines this logger with the specified logger to produce a new logger that logs to both this logger and that logger.
Signature
export declare const zip: {
<Message2, Output2>(
that: Logger<Message2, Output2>
): <Message, Output>(self: Logger<Message, Output>) => Logger<Message & Message2, [Output, Output2]>
<Message, Output, Message2, Output2>(
self: Logger<Message, Output>,
that: Logger<Message2, Output2>
): Logger<Message & Message2, [Output, Output2]>
}
Added in v2.0.0
zipLeft
Signature
export declare const zipLeft: {
<Message2, Output2>(
that: Logger<Message2, Output2>
): <Message, Output>(self: Logger<Message, Output>) => Logger<Message & Message2, Output>
<Message, Output, Message2, Output2>(
self: Logger<Message, Output>,
that: Logger<Message2, Output2>
): Logger<Message & Message2, Output>
}
Added in v2.0.0
zipRight
Signature
export declare const zipRight: {
<Message2, Output2>(
that: Logger<Message2, Output2>
): <Message, Output>(self: Logger<Message, Output>) => Logger<Message & Message2, Output2>
<Message, Output, Message2, Output2>(
self: Logger<Message, Output>,
that: Logger<Message2, Output2>
): Logger<Message & Message2, Output2>
}
Added in v2.0.0