Skip to main content Link Search Menu Expand Document (external link)

Logger overview

Added in v1.0.0


Table of contents


constructors

defaultLogger

Signature

export declare const defaultLogger: Logger<unknown, void>

Added in v1.0.0

logFmt

Signature

export declare const logFmt: Layer.Layer<never, never, never>

Added in v1.0.0

logfmtLogger

Signature

export declare const logfmtLogger: Logger<unknown, string>

Added in v1.0.0

make

Signature

export declare const make: <Message, Output>(
  log: (options: {
    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, AnnotationValue>
    readonly date: Date
  }) => Output
) => Logger<Message, Output>

Added in v1.0.0

none

A logger that does nothing in response to logging events.

Signature

export declare const none: Logger<unknown, void>

Added in v1.0.0

simple

Signature

export declare const simple: <A, B>(log: (a: A) => B) => Logger<A, B>

Added in v1.0.0

stringLogger

Signature

export declare const stringLogger: Logger<unknown, string>

Added in v1.0.0

succeed

Signature

export declare const succeed: <A>(value: A) => Logger<unknown, A>

Added in v1.0.0

sync

Signature

export declare const sync: <A>(evaluate: LazyArg<A>) => Logger<unknown, A>

Added in v1.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 v1.0.0

tracerLogger

Signature

export declare const tracerLogger: Logger<unknown, void>

Added in v1.0.0

context

add

Signature

export declare const add: <B>(logger: Logger<unknown, B>) => Layer.Layer<never, never, never>

Added in v1.0.0

addEffect

Signature

export declare const addEffect: <R, E, A>(effect: Effect<R, E, Logger<unknown, A>>) => Layer.Layer<R, E, never>

Added in v1.0.0

addScoped

Signature

export declare const addScoped: <R, E, A>(
  effect: Effect<R, E, Logger<unknown, A>>
) => Layer.Layer<Exclude<R, Scope>, E, never>

Added in v1.0.0

minimumLogLevel

Signature

export declare const minimumLogLevel: (level: LogLevel.LogLevel) => Layer.Layer<never, never, never>

Added in v1.0.0

remove

Signature

export declare const remove: <A>(logger: Logger<unknown, A>) => Layer.Layer<never, never, never>

Added in v1.0.0

replace

Signature

export declare const replace: {
  <B>(that: Logger<unknown, B>): <A>(self: Logger<unknown, A>) => Layer.Layer<never, never, never>
  <A, B>(self: Logger<unknown, A>, that: Logger<unknown, B>): Layer.Layer<never, never, never>
}

Added in v1.0.0

replaceEffect

Signature

export declare const replaceEffect: {
  <R, E, B>(that: Effect<R, E, Logger<unknown, B>>): <A>(self: Logger<unknown, A>) => Layer.Layer<R, E, never>
  <A, R, E, B>(self: Logger<unknown, A>, that: Effect<R, E, Logger<unknown, B>>): Layer.Layer<R, E, never>
}

Added in v1.0.0

replaceScoped

Signature

export declare const replaceScoped: {
  <R, E, B>(that: Effect<R, E, Logger<unknown, B>>): <A>(
    self: Logger<unknown, A>
  ) => Layer.Layer<Exclude<R, Scope>, E, never>
  <A, R, E, B>(self: Logger<unknown, A>, that: Effect<R, E, Logger<unknown, B>>): Layer.Layer<
    Exclude<R, Scope>,
    E,
    never
  >
}

Added in v1.0.0

withMinimumLogLevel

Signature

export declare const withMinimumLogLevel: {
  (level: LogLevel.LogLevel): <R, E, A>(self: Effect<R, E, A>) => Effect<R, E, A>
  <R, E, A>(self: Effect<R, E, A>, level: LogLevel.LogLevel): Effect<R, E, A>
}

Added in v1.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 v1.0.0

mapping

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 v1.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 v1.0.0

models

AnnotationValue (type alias)

Signature

export type AnnotationValue = string | number | boolean

Added in v1.0.0

Logger (interface)

Signature

export interface Logger<Message, Output> extends Logger.Variance<Message, Output>, Pipeable {
  readonly log: (options: {
    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, AnnotationValue>
    readonly date: Date
  }) => Output
}

Added in v1.0.0

symbols

LoggerTypeId

Signature

export declare const LoggerTypeId: typeof LoggerTypeId

Added in v1.0.0

LoggerTypeId (type alias)

Signature

export type LoggerTypeId = typeof LoggerTypeId

Added in v1.0.0

utils

Logger (namespace)

Added in v1.0.0

Variance (interface)

Signature

export interface Variance<Message, Output> {
  readonly [LoggerTypeId]: {
    readonly _Message: (_: Message) => void
    readonly _Output: (_: never) => Output
  }
}

Added in v1.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, readonly [Output, Output2]>
  <Message, Output, Message2, Output2>(self: Logger<Message, Output>, that: Logger<Message2, Output2>): Logger<
    Message & Message2,
    readonly [Output, Output2]
  >
}

Added in v1.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 v1.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 v1.0.0