@effect/io
Advanced tools
Comparing version 0.33.0 to 0.34.0
@@ -6,4 +6,4 @@ "use strict"; | ||
}); | ||
exports.tryPromise = exports.tryMapPromiseInterrupt = exports.tryMapPromise = exports.tryMap = exports.tracerWith = exports.tracer = exports.timedWith = exports.timed = exports.tapErrorCause = exports.tapError = exports.tapDefect = exports.tapBoth = exports.takeWhile = exports.takeUntil = exports.tagMetrics = exports.summarized = exports.succeedSome = exports.succeedNone = exports.spanAnnotations = exports.some = exports.sleep = exports.setFiberRefs = exports.serviceFunctionEffect = exports.serviceFunction = exports.sandbox = exports.repeatN = exports.reduceWhile = exports.reduceRight = exports.reduce = exports.random = exports.provideServiceEffect = exports.provideService = exports.promiseInterrupt = exports.promise = exports.patchFiberRefs = exports.parallelErrors = exports.orElseSucceed = exports.orElseFail = exports.option = exports.once = exports.none = exports.negate = exports.merge = exports.memoize = exports.match = exports.mapErrorCause = exports.mapAccum = exports.loop = exports.logCause = exports.logAnnotations = exports.log = exports.labelMetricsSet = exports.labelMetrics = exports.iterate = exports.isSuccess = exports.isFailure = exports.inheritFiberRefs = exports.ignoreLogged = exports.ignore = exports.head = exports.getFiberRefs = exports.gen = exports.forever = exports.flipWith = exports.firstSuccessOf = exports.findFirst = exports.filterOrFail = exports.filterOrElse = exports.filterOrDieMessage = exports.filterOrDie = exports.filterMap = exports.every = exports.eventually = exports.dropWhile = exports.dropUntil = exports.diffFiberRefs = exports.descriptorWith = exports.descriptor = exports.delay = exports.currentSpan = exports.contextWith = exports.clockWith = exports.clock = exports.cause = exports.catchTags = exports.catchTag = exports.catchSomeDefect = exports.catchSomeCause = exports.catchAllDefect = exports.bindValue = exports.bindTo = exports.bind = exports.asyncOption = exports.asSomeError = exports.asSome = exports.annotateSpans = exports.annotateLogs = exports.allowInterrupt = exports._catch = exports.Do = void 0; | ||
exports.withSpan = exports.withMetric = exports.withLogSpan = exports.withLogCause = exports.withLog = exports.whenRef = exports.whenFiberRef = exports.when = exports.useSpan = exports.updateService = exports.updateFiberRefs = exports.unsandbox = exports.unlessEffect = exports.unless = exports.try_ = exports.tryPromiseInterrupt = void 0; | ||
exports.tracer = exports.timedWith = exports.timed = exports.tapErrorCause = exports.tapError = exports.tapDefect = exports.tapBoth = exports.takeWhile = exports.takeUntil = exports.tagMetrics = exports.summarized = exports.succeedSome = exports.succeedNone = exports.spanAnnotations = exports.some = exports.sleep = exports.setFiberRefs = exports.serviceFunctionEffect = exports.serviceFunction = exports.sandbox = exports.repeatN = exports.reduceWhile = exports.reduceRight = exports.reduce = exports.random = exports.provideServiceEffect = exports.provideService = exports.promiseInterrupt = exports.promise = exports.patchFiberRefs = exports.parallelErrors = exports.orElseSucceed = exports.orElseFail = exports.option = exports.once = exports.none = exports.negate = exports.merge = exports.memoize = exports.match = exports.mapErrorCause = exports.mapAccum = exports.loop = exports.logWarning = exports.logTrace = exports.logInfo = exports.logFatal = exports.logError = exports.logDebug = exports.logAnnotations = exports.log = exports.labelMetricsSet = exports.labelMetrics = exports.iterate = exports.isSuccess = exports.isFailure = exports.inheritFiberRefs = exports.ignoreLogged = exports.ignore = exports.head = exports.getFiberRefs = exports.gen = exports.forever = exports.flipWith = exports.firstSuccessOf = exports.findFirst = exports.filterOrFail = exports.filterOrElse = exports.filterOrDieMessage = exports.filterOrDie = exports.filterMap = exports.every = exports.eventually = exports.dropWhile = exports.dropUntil = exports.diffFiberRefs = exports.descriptorWith = exports.descriptor = exports.delay = exports.currentSpan = exports.contextWith = exports.clockWith = exports.clock = exports.cause = exports.catchTags = exports.catchTag = exports.catchSomeDefect = exports.catchSomeCause = exports.catchAllDefect = exports.bindValue = exports.bindTo = exports.bind = exports.asyncOption = exports.asSomeError = exports.asSome = exports.annotateSpans = exports.annotateLogs = exports.allowInterrupt = exports._catch = exports.Do = void 0; | ||
exports.withSpan = exports.withMetric = exports.withLogSpan = exports.whenRef = exports.whenFiberRef = exports.when = exports.useSpan = exports.updateService = exports.updateFiberRefs = exports.unsandbox = exports.unlessEffect = exports.unless = exports.try_ = exports.tryPromiseInterrupt = exports.tryPromise = exports.tryMapPromiseInterrupt = exports.tryMapPromise = exports.tryMap = exports.tracerWith = void 0; | ||
var Chunk = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Chunk")); | ||
@@ -376,5 +376,3 @@ var Context = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Context")); | ||
const ignoreLogged = self => core.matchCauseEffect(self, { | ||
onFailure: cause => logCause(cause, "Debug", { | ||
message: "An error was silently ignored because it is not anticipated to be useful" | ||
}), | ||
onFailure: cause => logDebug(cause, "An error was silently ignored because it is not anticipated to be useful"), | ||
onSuccess: () => core.unit | ||
@@ -405,22 +403,34 @@ }); | ||
}); | ||
/* @internal */ | ||
exports.iterate = iterate; | ||
const log = (message, level, options) => core.withFiberRuntime(fiberState => { | ||
fiberState.log(message, options?.cause ?? internalCause.empty, level ? Option.some(LogLevel.fromLiteral(level)) : Option.none()); | ||
return core.unit; | ||
}); | ||
/* @internal */ | ||
const logWithLevel = level => (messageOrCause, supplementry) => { | ||
const message = typeof messageOrCause === "string" ? messageOrCause : ""; | ||
const cause = internalCause.isCause(supplementry) ? supplementry : internalCause.empty; | ||
const levelOption = Option.fromNullable(level); | ||
return core.withFiberRuntime(fiberState => { | ||
fiberState.log(message, cause, levelOption); | ||
return core.unit; | ||
}); | ||
}; | ||
/** @internal */ | ||
const log = /*#__PURE__*/logWithLevel(); | ||
/** @internal */ | ||
exports.log = log; | ||
const logCause = /*#__PURE__*/(0, _Function.dual)(args => internalCause.isCause(args[0]), (cause, level, options) => core.withFiberRuntime(fiberState => { | ||
fiberState.log(options?.message ?? "", cause, level ? Option.some(LogLevel.fromLiteral(level)) : Option.none()); | ||
return core.unit; | ||
})); | ||
const logTrace = /*#__PURE__*/logWithLevel(LogLevel.Trace); | ||
/** @internal */ | ||
exports.logTrace = logTrace; | ||
const logDebug = /*#__PURE__*/logWithLevel(LogLevel.Debug); | ||
/** @internal */ | ||
exports.logDebug = logDebug; | ||
const logInfo = /*#__PURE__*/logWithLevel(LogLevel.Info); | ||
/** @internal */ | ||
exports.logInfo = logInfo; | ||
const logWarning = /*#__PURE__*/logWithLevel(LogLevel.Warning); | ||
/** @internal */ | ||
exports.logWarning = logWarning; | ||
const logError = /*#__PURE__*/logWithLevel(LogLevel.Error); | ||
/** @internal */ | ||
exports.logError = logError; | ||
const logFatal = /*#__PURE__*/logWithLevel(LogLevel.Fatal); | ||
/* @internal */ | ||
exports.logCause = logCause; | ||
const withLog = /*#__PURE__*/(0, _Function.dual)(args => core.isEffect(args[0]), (self, message, level, options) => core.zipLeft(self, log(message, level, options))); | ||
/* @internal */ | ||
exports.withLog = withLog; | ||
const withLogCause = /*#__PURE__*/(0, _Function.dual)(args => core.isEffect(args[0]), (self, level, options) => tapErrorCause(self, logCause(level, options))); | ||
/* @internal */ | ||
exports.withLogCause = withLogCause; | ||
exports.logFatal = logFatal; | ||
const withLogSpan = /*#__PURE__*/(0, _Function.dual)(2, (effect, label) => core.flatMap(core.fiberRefGet(core.currentLogSpan), stack => core.flatMap(Clock.currentTimeMillis, now => core.suspend(() => core.fiberRefLocally(core.currentLogSpan, List.prepend(stack, LogSpan.make(label, now)))(effect))))); | ||
@@ -427,0 +437,0 @@ /* @internal */ |
@@ -166,3 +166,3 @@ "use strict"; | ||
warningStart() { | ||
return synchronized.updateSomeEffect(this.warningState, data => WarningData.isStart(data) ? Option.some(core.map(fiber => WarningData.pending(fiber))(fiberRuntime.fork(core.interruptible(this.live.provide(effect.delay(Duration.seconds(5))(effect.log(warning, "Warning"))))))) : Option.none()); | ||
return synchronized.updateSomeEffect(this.warningState, data => WarningData.isStart(data) ? Option.some(core.map(fiber => WarningData.pending(fiber))(fiberRuntime.fork(core.interruptible(this.live.provide(effect.delay(Duration.seconds(5))(effect.logWarning(warning))))))) : Option.none()); | ||
} | ||
@@ -203,3 +203,3 @@ /** | ||
if (SuspendedWarningData.isStart(suspendedWarningData)) { | ||
return Option.some(core.map(fiber => SuspendedWarningData.pending(fiber))(fiberRuntime.fork(core.interruptible(this.live.provide(effect.delay(Duration.seconds(5))(core.zipRight(ref.set(this.suspendedWarningState, SuspendedWarningData.done))(effect.log(suspendedWarning, "Warning")))))))); | ||
return Option.some(core.map(fiber => SuspendedWarningData.pending(fiber))(fiberRuntime.fork(core.interruptible(this.live.provide(effect.delay(Duration.seconds(5))(core.zipRight(ref.set(this.suspendedWarningState, SuspendedWarningData.done))(effect.logWarning(suspendedWarning)))))))); | ||
} | ||
@@ -206,0 +206,0 @@ return Option.none(); |
{ | ||
"name": "@effect/io", | ||
"version": "0.33.0", | ||
"version": "0.34.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -833,6 +833,3 @@ import * as Chunk from "@effect/data/Chunk" | ||
core.matchCauseEffect(self, { | ||
onFailure: (cause) => | ||
logCause(cause, "Debug", { | ||
message: "An error was silently ignored because it is not anticipated to be useful" | ||
}), | ||
onFailure: (cause) => logDebug(cause, "An error was silently ignored because it is not anticipated to be useful"), | ||
onSuccess: () => core.unit | ||
@@ -868,68 +865,58 @@ }) | ||
/* @internal */ | ||
export const log = (message: string, level?: LogLevel.Literal, options?: { | ||
readonly cause?: Cause.Cause<unknown> | ||
}): Effect.Effect<never, never, void> => | ||
core.withFiberRuntime<never, never, void>((fiberState) => { | ||
fiberState.log( | ||
message, | ||
options?.cause ?? internalCause.empty, | ||
level ? Option.some(LogLevel.fromLiteral(level)) : Option.none() | ||
) | ||
return core.unit | ||
}) | ||
/* @internal */ | ||
export const logCause = dual< | ||
(level?: LogLevel.Literal, options?: { | ||
readonly message?: string | ||
}) => (cause: Cause.Cause<unknown>) => Effect.Effect<never, never, void>, | ||
(cause: Cause.Cause<unknown>, level?: LogLevel.Literal, options?: { | ||
readonly message?: string | ||
}) => Effect.Effect<never, never, void> | ||
>( | ||
(args) => internalCause.isCause(args[0]), | ||
(cause: Cause.Cause<unknown>, level?: LogLevel.Literal, options?: { | ||
readonly message?: string | ||
}): Effect.Effect<never, never, void> => | ||
core.withFiberRuntime<never, never, void>((fiberState) => { | ||
fiberState.log( | ||
options?.message ?? "", | ||
cause, | ||
level ? Option.some(LogLevel.fromLiteral(level)) : Option.none() | ||
) | ||
const logWithLevel = (level?: LogLevel.LogLevel) => | ||
<A extends string | Cause.Cause<unknown>>( | ||
messageOrCause: A, | ||
supplementry?: A extends string ? Cause.Cause<unknown> : string | ||
): Effect.Effect<never, never, void> => { | ||
const message = typeof messageOrCause === "string" ? messageOrCause : "" | ||
const cause: Cause.Cause<unknown> = internalCause.isCause(supplementry) ? supplementry : internalCause.empty | ||
const levelOption = Option.fromNullable(level) | ||
return core.withFiberRuntime<never, never, void>((fiberState) => { | ||
fiberState.log(message, cause, levelOption) | ||
return core.unit | ||
}) | ||
) | ||
} | ||
/* @internal */ | ||
export const withLog = dual< | ||
(message: string, level?: LogLevel.Literal, options?: { | ||
readonly cause?: Cause.Cause<unknown> | ||
}) => <R, E, A>(self: Effect.Effect<R, E, A>) => Effect.Effect<R, E, A>, | ||
<R, E, A>(self: Effect.Effect<R, E, A>, message: string, level?: LogLevel.Literal, options?: { | ||
readonly cause?: Cause.Cause<unknown> | ||
}) => Effect.Effect<R, E, A> | ||
>( | ||
(args) => core.isEffect(args[0]), | ||
<R, E, A>(self: Effect.Effect<R, E, A>, message: string, level?: LogLevel.Literal, options?: { | ||
readonly cause?: Cause.Cause<unknown> | ||
}): Effect.Effect<R, E, A> => core.zipLeft(self, log(message, level, options)) | ||
) | ||
/** @internal */ | ||
export const log: <A extends string | Cause.Cause<unknown>>( | ||
messageOrCause: A, | ||
supplementry?: A extends string ? Cause.Cause<unknown> : string | ||
) => Effect.Effect<never, never, void> = logWithLevel() | ||
/* @internal */ | ||
export const withLogCause = dual< | ||
(level?: LogLevel.Literal, options?: { | ||
readonly message?: string | ||
}) => <R, E, A>(self: Effect.Effect<R, E, A>) => Effect.Effect<R, E, A>, | ||
<R, E, A>(self: Effect.Effect<R, E, A>, level?: LogLevel.Literal, options?: { | ||
readonly message?: string | ||
}) => Effect.Effect<R, E, A> | ||
>( | ||
(args) => core.isEffect(args[0]), | ||
<R, E, A>(self: Effect.Effect<R, E, A>, level?: LogLevel.Literal, options?: { | ||
readonly message?: string | ||
}): Effect.Effect<R, E, A> => tapErrorCause(self, logCause(level, options)) | ||
) | ||
/** @internal */ | ||
export const logTrace: <A extends string | Cause.Cause<unknown>>( | ||
messageOrCause: A, | ||
supplementry?: A extends string ? Cause.Cause<unknown> : string | ||
) => Effect.Effect<never, never, void> = logWithLevel(LogLevel.Trace) | ||
/** @internal */ | ||
export const logDebug: <A extends string | Cause.Cause<unknown>>( | ||
messageOrCause: A, | ||
supplementry?: A extends string ? Cause.Cause<unknown> : string | ||
) => Effect.Effect<never, never, void> = logWithLevel(LogLevel.Debug) | ||
/** @internal */ | ||
export const logInfo: <A extends string | Cause.Cause<unknown>>( | ||
messageOrCause: A, | ||
supplementry?: A extends string ? Cause.Cause<unknown> : string | ||
) => Effect.Effect<never, never, void> = logWithLevel(LogLevel.Info) | ||
/** @internal */ | ||
export const logWarning: <A extends string | Cause.Cause<unknown>>( | ||
messageOrCause: A, | ||
supplementry?: A extends string ? Cause.Cause<unknown> : string | ||
) => Effect.Effect<never, never, void> = logWithLevel(LogLevel.Warning) | ||
/** @internal */ | ||
export const logError: <A extends string | Cause.Cause<unknown>>( | ||
messageOrCause: A, | ||
supplementry?: A extends string ? Cause.Cause<unknown> : string | ||
) => Effect.Effect<never, never, void> = logWithLevel(LogLevel.Error) | ||
/** @internal */ | ||
export const logFatal: <A extends string | Cause.Cause<unknown>>( | ||
messageOrCause: A, | ||
supplementry?: A extends string ? Cause.Cause<unknown> : string | ||
) => Effect.Effect<never, never, void> = logWithLevel(LogLevel.Fatal) | ||
/* @internal */ | ||
@@ -936,0 +923,0 @@ export const withLogSpan = dual< |
@@ -261,3 +261,3 @@ import * as Chunk from "@effect/data/Chunk" | ||
this.live.provide( | ||
pipe(effect.log(warning, "Warning"), effect.delay(Duration.seconds(5))) | ||
pipe(effect.logWarning(warning), effect.delay(Duration.seconds(5))) | ||
), | ||
@@ -331,3 +331,3 @@ core.interruptible, | ||
pipe( | ||
effect.log(suspendedWarning, "Warning"), | ||
effect.logWarning(suspendedWarning), | ||
core.zipRight(ref.set(this.suspendedWarningState, SuspendedWarningData.done)), | ||
@@ -334,0 +334,0 @@ effect.delay(Duration.seconds(5)) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6374309
113796