@clayroach/effect 3.19.14-source-capture.6 → 3.19.14-source-capture.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Utils.js +1 -1
- package/dist/cjs/Utils.js.map +1 -1
- package/dist/cjs/internal/clock.js +1 -1
- package/dist/cjs/internal/clock.js.map +1 -1
- package/dist/esm/Utils.js +1 -1
- package/dist/esm/Utils.js.map +1 -1
- package/dist/esm/internal/clock.js +1 -1
- package/dist/esm/internal/clock.js.map +1 -1
- package/package.json +1 -1
- package/src/Arbitrary.ts +0 -1101
- package/src/Array.ts +0 -3589
- package/src/BigDecimal.ts +0 -1349
- package/src/BigInt.ts +0 -643
- package/src/Boolean.ts +0 -287
- package/src/Brand.ts +0 -360
- package/src/Cache.ts +0 -281
- package/src/Cause.ts +0 -1555
- package/src/Channel.ts +0 -2355
- package/src/ChildExecutorDecision.ts +0 -146
- package/src/Chunk.ts +0 -1495
- package/src/Clock.ts +0 -111
- package/src/Config.ts +0 -542
- package/src/ConfigError.ts +0 -270
- package/src/ConfigProvider.ts +0 -333
- package/src/ConfigProviderPathPatch.ts +0 -100
- package/src/Console.ts +0 -226
- package/src/Context.ts +0 -585
- package/src/Cron.ts +0 -706
- package/src/Data.ts +0 -596
- package/src/DateTime.ts +0 -1686
- package/src/DefaultServices.ts +0 -34
- package/src/Deferred.ts +0 -301
- package/src/Differ.ts +0 -450
- package/src/Duration.ts +0 -1000
- package/src/Effect.ts +0 -14839
- package/src/Effectable.ts +0 -107
- package/src/Either.ts +0 -1040
- package/src/Encoding.ts +0 -195
- package/src/Equal.ts +0 -98
- package/src/Equivalence.ts +0 -235
- package/src/ExecutionPlan.ts +0 -308
- package/src/ExecutionStrategy.ts +0 -119
- package/src/Exit.ts +0 -467
- package/src/FastCheck.ts +0 -9
- package/src/Fiber.ts +0 -744
- package/src/FiberHandle.ts +0 -540
- package/src/FiberId.ts +0 -195
- package/src/FiberMap.ts +0 -656
- package/src/FiberRef.ts +0 -431
- package/src/FiberRefs.ts +0 -204
- package/src/FiberRefsPatch.ts +0 -105
- package/src/FiberSet.ts +0 -491
- package/src/FiberStatus.ts +0 -108
- package/src/Function.ts +0 -1222
- package/src/GlobalValue.ts +0 -53
- package/src/Graph.ts +0 -3732
- package/src/GroupBy.ts +0 -103
- package/src/HKT.ts +0 -45
- package/src/Hash.ts +0 -195
- package/src/HashMap.ts +0 -519
- package/src/HashRing.ts +0 -317
- package/src/HashSet.ts +0 -2346
- package/src/Inspectable.ts +0 -287
- package/src/Iterable.ts +0 -1119
- package/src/JSONSchema.ts +0 -1044
- package/src/KeyedPool.ts +0 -167
- package/src/Layer.ts +0 -1251
- package/src/LayerMap.ts +0 -436
- package/src/List.ts +0 -977
- package/src/LogLevel.ts +0 -285
- package/src/LogSpan.ts +0 -25
- package/src/Logger.ts +0 -702
- package/src/Mailbox.ts +0 -268
- package/src/ManagedRuntime.ts +0 -180
- package/src/Match.ts +0 -1477
- package/src/MergeDecision.ts +0 -95
- package/src/MergeState.ts +0 -172
- package/src/MergeStrategy.ts +0 -107
- package/src/Metric.ts +0 -780
- package/src/MetricBoundaries.ts +0 -69
- package/src/MetricHook.ts +0 -151
- package/src/MetricKey.ts +0 -224
- package/src/MetricKeyType.ts +0 -262
- package/src/MetricLabel.ts +0 -47
- package/src/MetricPair.ts +0 -71
- package/src/MetricPolling.ts +0 -148
- package/src/MetricRegistry.ts +0 -48
- package/src/MetricState.ts +0 -257
- package/src/Micro.ts +0 -4405
- package/src/ModuleVersion.ts +0 -18
- package/src/MutableHashMap.ts +0 -411
- package/src/MutableHashSet.ts +0 -706
- package/src/MutableList.ts +0 -297
- package/src/MutableQueue.ts +0 -227
- package/src/MutableRef.ts +0 -202
- package/src/NonEmptyIterable.ts +0 -32
- package/src/Number.ts +0 -1071
- package/src/Option.ts +0 -2170
- package/src/Order.ts +0 -373
- package/src/Ordering.ts +0 -111
- package/src/ParseResult.ts +0 -2031
- package/src/PartitionedSemaphore.ts +0 -200
- package/src/Pipeable.ts +0 -566
- package/src/Pool.ts +0 -204
- package/src/Predicate.ts +0 -1405
- package/src/Pretty.ts +0 -205
- package/src/PrimaryKey.ts +0 -23
- package/src/PubSub.ts +0 -182
- package/src/Queue.ts +0 -644
- package/src/Random.ts +0 -204
- package/src/RateLimiter.ts +0 -138
- package/src/RcMap.ts +0 -141
- package/src/RcRef.ts +0 -122
- package/src/Readable.ts +0 -93
- package/src/Record.ts +0 -1274
- package/src/RedBlackTree.ts +0 -421
- package/src/Redacted.ts +0 -144
- package/src/Ref.ts +0 -180
- package/src/RegExp.ts +0 -38
- package/src/Reloadable.ts +0 -127
- package/src/Request.ts +0 -347
- package/src/RequestBlock.ts +0 -118
- package/src/RequestResolver.ts +0 -366
- package/src/Resource.ts +0 -119
- package/src/Runtime.ts +0 -383
- package/src/RuntimeFlags.ts +0 -368
- package/src/RuntimeFlagsPatch.ts +0 -183
- package/src/STM.ts +0 -2045
- package/src/Schedule.ts +0 -2219
- package/src/ScheduleDecision.ts +0 -62
- package/src/ScheduleInterval.ts +0 -151
- package/src/ScheduleIntervals.ts +0 -122
- package/src/Scheduler.ts +0 -353
- package/src/Schema.ts +0 -10914
- package/src/SchemaAST.ts +0 -3043
- package/src/Scope.ts +0 -204
- package/src/ScopedCache.ts +0 -151
- package/src/ScopedRef.ts +0 -117
- package/src/Secret.ts +0 -88
- package/src/SingleProducerAsyncInput.ts +0 -67
- package/src/Sink.ts +0 -1461
- package/src/SortedMap.ts +0 -287
- package/src/SortedSet.ts +0 -390
- package/src/Stream.ts +0 -6468
- package/src/StreamEmit.ts +0 -136
- package/src/StreamHaltStrategy.ts +0 -123
- package/src/Streamable.ts +0 -45
- package/src/String.ts +0 -778
- package/src/Struct.ts +0 -243
- package/src/Subscribable.ts +0 -100
- package/src/SubscriptionRef.ts +0 -298
- package/src/Supervisor.ts +0 -240
- package/src/Symbol.ts +0 -29
- package/src/SynchronizedRef.ts +0 -270
- package/src/TArray.ts +0 -495
- package/src/TDeferred.ts +0 -100
- package/src/TMap.ts +0 -515
- package/src/TPriorityQueue.ts +0 -223
- package/src/TPubSub.ts +0 -200
- package/src/TQueue.ts +0 -432
- package/src/TRandom.ts +0 -129
- package/src/TReentrantLock.ts +0 -224
- package/src/TRef.ts +0 -178
- package/src/TSemaphore.ts +0 -129
- package/src/TSet.ts +0 -365
- package/src/TSubscriptionRef.ts +0 -192
- package/src/Take.ts +0 -258
- package/src/TestAnnotation.ts +0 -158
- package/src/TestAnnotationMap.ts +0 -119
- package/src/TestAnnotations.ts +0 -117
- package/src/TestClock.ts +0 -556
- package/src/TestConfig.ts +0 -47
- package/src/TestContext.ts +0 -36
- package/src/TestLive.ts +0 -53
- package/src/TestServices.ts +0 -390
- package/src/TestSized.ts +0 -55
- package/src/Tracer.ts +0 -198
- package/src/Trie.ts +0 -840
- package/src/Tuple.ts +0 -305
- package/src/Types.ts +0 -353
- package/src/Unify.ts +0 -113
- package/src/UpstreamPullRequest.ts +0 -117
- package/src/UpstreamPullStrategy.ts +0 -121
- package/src/Utils.ts +0 -809
- package/src/index.ts +0 -1561
- package/src/internal/array.ts +0 -8
- package/src/internal/blockedRequests.ts +0 -520
- package/src/internal/cache.ts +0 -733
- package/src/internal/cause.ts +0 -1050
- package/src/internal/channel/channelExecutor.ts +0 -1200
- package/src/internal/channel/channelState.ts +0 -134
- package/src/internal/channel/childExecutorDecision.ts +0 -96
- package/src/internal/channel/continuation.ts +0 -200
- package/src/internal/channel/mergeDecision.ts +0 -113
- package/src/internal/channel/mergeState.ts +0 -120
- package/src/internal/channel/mergeStrategy.ts +0 -72
- package/src/internal/channel/singleProducerAsyncInput.ts +0 -259
- package/src/internal/channel/subexecutor.ts +0 -229
- package/src/internal/channel/upstreamPullRequest.ts +0 -84
- package/src/internal/channel/upstreamPullStrategy.ts +0 -87
- package/src/internal/channel.ts +0 -2603
- package/src/internal/clock.ts +0 -95
- package/src/internal/completedRequestMap.ts +0 -9
- package/src/internal/concurrency.ts +0 -54
- package/src/internal/config.ts +0 -716
- package/src/internal/configError.ts +0 -304
- package/src/internal/configProvider/pathPatch.ts +0 -97
- package/src/internal/configProvider.ts +0 -799
- package/src/internal/console.ts +0 -153
- package/src/internal/context.ts +0 -337
- package/src/internal/core-effect.ts +0 -2293
- package/src/internal/core-stream.ts +0 -998
- package/src/internal/core.ts +0 -3273
- package/src/internal/data.ts +0 -36
- package/src/internal/dataSource.ts +0 -327
- package/src/internal/dateTime.ts +0 -1277
- package/src/internal/defaultServices/console.ts +0 -100
- package/src/internal/defaultServices.ts +0 -163
- package/src/internal/deferred.ts +0 -46
- package/src/internal/differ/chunkPatch.ts +0 -211
- package/src/internal/differ/contextPatch.ts +0 -232
- package/src/internal/differ/hashMapPatch.ts +0 -220
- package/src/internal/differ/hashSetPatch.ts +0 -176
- package/src/internal/differ/orPatch.ts +0 -311
- package/src/internal/differ/readonlyArrayPatch.ts +0 -210
- package/src/internal/differ.ts +0 -200
- package/src/internal/doNotation.ts +0 -80
- package/src/internal/effect/circular.ts +0 -905
- package/src/internal/effectable.ts +0 -131
- package/src/internal/either.ts +0 -110
- package/src/internal/encoding/base64.ts +0 -286
- package/src/internal/encoding/base64Url.ts +0 -29
- package/src/internal/encoding/common.ts +0 -51
- package/src/internal/encoding/hex.ts +0 -315
- package/src/internal/errors.ts +0 -7
- package/src/internal/executionPlan.ts +0 -114
- package/src/internal/executionStrategy.ts +0 -74
- package/src/internal/fiber.ts +0 -388
- package/src/internal/fiberId.ts +0 -267
- package/src/internal/fiberMessage.ts +0 -82
- package/src/internal/fiberRefs/patch.ts +0 -144
- package/src/internal/fiberRefs.ts +0 -297
- package/src/internal/fiberRuntime.ts +0 -3915
- package/src/internal/fiberScope.ts +0 -71
- package/src/internal/fiberStatus.ts +0 -119
- package/src/internal/groupBy.ts +0 -530
- package/src/internal/hashMap/array.ts +0 -49
- package/src/internal/hashMap/bitwise.ts +0 -32
- package/src/internal/hashMap/config.ts +0 -14
- package/src/internal/hashMap/keySet.ts +0 -8
- package/src/internal/hashMap/node.ts +0 -391
- package/src/internal/hashMap.ts +0 -586
- package/src/internal/hashSet.ts +0 -323
- package/src/internal/keyedPool.ts +0 -244
- package/src/internal/layer/circular.ts +0 -228
- package/src/internal/layer.ts +0 -1487
- package/src/internal/logSpan.ts +0 -20
- package/src/internal/logger-circular.ts +0 -24
- package/src/internal/logger.ts +0 -485
- package/src/internal/mailbox.ts +0 -561
- package/src/internal/managedRuntime/circular.ts +0 -6
- package/src/internal/managedRuntime.ts +0 -134
- package/src/internal/matcher.ts +0 -652
- package/src/internal/metric/boundaries.ts +0 -75
- package/src/internal/metric/hook.ts +0 -483
- package/src/internal/metric/key.ts +0 -167
- package/src/internal/metric/keyType.ts +0 -238
- package/src/internal/metric/label.ts +0 -41
- package/src/internal/metric/pair.ts +0 -48
- package/src/internal/metric/polling.ts +0 -149
- package/src/internal/metric/registry.ts +0 -187
- package/src/internal/metric/state.ts +0 -290
- package/src/internal/metric.ts +0 -577
- package/src/internal/opCodes/cause.ts +0 -35
- package/src/internal/opCodes/channel.ts +0 -83
- package/src/internal/opCodes/channelChildExecutorDecision.ts +0 -17
- package/src/internal/opCodes/channelMergeDecision.ts +0 -11
- package/src/internal/opCodes/channelMergeState.ts +0 -17
- package/src/internal/opCodes/channelMergeStrategy.ts +0 -11
- package/src/internal/opCodes/channelState.ts +0 -23
- package/src/internal/opCodes/channelUpstreamPullRequest.ts +0 -11
- package/src/internal/opCodes/channelUpstreamPullStrategy.ts +0 -11
- package/src/internal/opCodes/config.ts +0 -65
- package/src/internal/opCodes/configError.ts +0 -35
- package/src/internal/opCodes/continuation.ts +0 -11
- package/src/internal/opCodes/deferred.ts +0 -11
- package/src/internal/opCodes/effect.ts +0 -89
- package/src/internal/opCodes/layer.ts +0 -59
- package/src/internal/opCodes/streamHaltStrategy.ts +0 -23
- package/src/internal/option.ts +0 -80
- package/src/internal/pool.ts +0 -432
- package/src/internal/pubsub.ts +0 -1762
- package/src/internal/query.ts +0 -204
- package/src/internal/queue.ts +0 -766
- package/src/internal/random.ts +0 -161
- package/src/internal/rateLimiter.ts +0 -93
- package/src/internal/rcMap.ts +0 -285
- package/src/internal/rcRef.ts +0 -192
- package/src/internal/redBlackTree/iterator.ts +0 -200
- package/src/internal/redBlackTree/node.ts +0 -68
- package/src/internal/redBlackTree.ts +0 -1245
- package/src/internal/redacted.ts +0 -73
- package/src/internal/ref.ts +0 -171
- package/src/internal/reloadable.ts +0 -140
- package/src/internal/request.ts +0 -177
- package/src/internal/resource.ts +0 -76
- package/src/internal/ringBuffer.ts +0 -68
- package/src/internal/runtime.ts +0 -558
- package/src/internal/runtimeFlags.ts +0 -188
- package/src/internal/runtimeFlagsPatch.ts +0 -103
- package/src/internal/schedule/decision.ts +0 -47
- package/src/internal/schedule/interval.ts +0 -101
- package/src/internal/schedule/intervals.ts +0 -180
- package/src/internal/schedule.ts +0 -2199
- package/src/internal/schema/errors.ts +0 -191
- package/src/internal/schema/schemaId.ts +0 -106
- package/src/internal/schema/util.ts +0 -50
- package/src/internal/scopedCache.ts +0 -644
- package/src/internal/scopedRef.ts +0 -118
- package/src/internal/secret.ts +0 -89
- package/src/internal/singleShotGen.ts +0 -35
- package/src/internal/sink.ts +0 -2120
- package/src/internal/stack.ts +0 -10
- package/src/internal/stm/core.ts +0 -817
- package/src/internal/stm/entry.ts +0 -59
- package/src/internal/stm/journal.ts +0 -123
- package/src/internal/stm/opCodes/stm.ts +0 -71
- package/src/internal/stm/opCodes/stmState.ts +0 -17
- package/src/internal/stm/opCodes/strategy.ts +0 -17
- package/src/internal/stm/opCodes/tExit.ts +0 -29
- package/src/internal/stm/opCodes/tryCommit.ts +0 -11
- package/src/internal/stm/stm.ts +0 -1453
- package/src/internal/stm/stmState.ts +0 -136
- package/src/internal/stm/tArray.ts +0 -550
- package/src/internal/stm/tDeferred.ts +0 -81
- package/src/internal/stm/tExit.ts +0 -190
- package/src/internal/stm/tMap.ts +0 -824
- package/src/internal/stm/tPriorityQueue.ts +0 -267
- package/src/internal/stm/tPubSub.ts +0 -551
- package/src/internal/stm/tQueue.ts +0 -393
- package/src/internal/stm/tRandom.ts +0 -140
- package/src/internal/stm/tReentrantLock.ts +0 -352
- package/src/internal/stm/tRef.ts +0 -195
- package/src/internal/stm/tSemaphore.ts +0 -113
- package/src/internal/stm/tSet.ts +0 -259
- package/src/internal/stm/tSubscriptionRef.ts +0 -286
- package/src/internal/stm/tryCommit.ts +0 -34
- package/src/internal/stm/txnId.ts +0 -14
- package/src/internal/stm/versioned.ts +0 -4
- package/src/internal/stream/debounceState.ts +0 -57
- package/src/internal/stream/emit.ts +0 -123
- package/src/internal/stream/haltStrategy.ts +0 -94
- package/src/internal/stream/handoff.ts +0 -187
- package/src/internal/stream/handoffSignal.ts +0 -59
- package/src/internal/stream/pull.ts +0 -34
- package/src/internal/stream/sinkEndReason.ts +0 -30
- package/src/internal/stream/zipAllState.ts +0 -88
- package/src/internal/stream/zipChunksState.ts +0 -56
- package/src/internal/stream.ts +0 -8801
- package/src/internal/string-utils.ts +0 -107
- package/src/internal/subscriptionRef.ts +0 -138
- package/src/internal/supervisor/patch.ts +0 -190
- package/src/internal/supervisor.ts +0 -303
- package/src/internal/synchronizedRef.ts +0 -114
- package/src/internal/take.ts +0 -199
- package/src/internal/testing/sleep.ts +0 -27
- package/src/internal/testing/suspendedWarningData.ts +0 -85
- package/src/internal/testing/warningData.ts +0 -94
- package/src/internal/tracer.ts +0 -293
- package/src/internal/trie.ts +0 -722
- package/src/internal/version.ts +0 -7
package/src/internal/logSpan.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type * as LogSpan from "../LogSpan.js"
|
|
2
|
-
|
|
3
|
-
/** @internal */
|
|
4
|
-
export const make = (label: string, startTime: number): LogSpan.LogSpan => ({
|
|
5
|
-
label,
|
|
6
|
-
startTime
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Sanitize a given string by replacing spaces, equal signs, and double quotes with underscores.
|
|
11
|
-
*
|
|
12
|
-
* @internal
|
|
13
|
-
*/
|
|
14
|
-
export const formatLabel = (key: string) => key.replace(/[\s="]/g, "_")
|
|
15
|
-
|
|
16
|
-
/** @internal */
|
|
17
|
-
export const render = (now: number) => (self: LogSpan.LogSpan): string => {
|
|
18
|
-
const label = formatLabel(self.label)
|
|
19
|
-
return `${label}=${now - self.startTime}ms`
|
|
20
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import * as Cause from "../Cause.js"
|
|
2
|
-
import { dual } from "../Function.js"
|
|
3
|
-
import * as HashMap from "../HashMap.js"
|
|
4
|
-
import * as List from "../List.js"
|
|
5
|
-
import type * as Logger from "../Logger.js"
|
|
6
|
-
import * as core from "./core.js"
|
|
7
|
-
import * as fiberId_ from "./fiberId.js"
|
|
8
|
-
import * as fiberRefs from "./fiberRefs.js"
|
|
9
|
-
|
|
10
|
-
/** @internal */
|
|
11
|
-
export const test = dual<
|
|
12
|
-
<Message>(input: Message) => <Output>(self: Logger.Logger<Message, Output>) => Output,
|
|
13
|
-
<Message, Output>(self: Logger.Logger<Message, Output>, input: Message) => Output
|
|
14
|
-
>(2, (self, input) =>
|
|
15
|
-
self.log({
|
|
16
|
-
fiberId: fiberId_.none,
|
|
17
|
-
logLevel: core.logLevelInfo,
|
|
18
|
-
message: input,
|
|
19
|
-
cause: Cause.empty,
|
|
20
|
-
context: fiberRefs.empty(),
|
|
21
|
-
spans: List.empty(),
|
|
22
|
-
annotations: HashMap.empty(),
|
|
23
|
-
date: new Date()
|
|
24
|
-
}))
|
package/src/internal/logger.ts
DELETED
|
@@ -1,485 +0,0 @@
|
|
|
1
|
-
import * as Arr from "../Array.js"
|
|
2
|
-
import * as Context from "../Context.js"
|
|
3
|
-
import * as FiberRefs from "../FiberRefs.js"
|
|
4
|
-
import type { LazyArg } from "../Function.js"
|
|
5
|
-
import { constVoid, dual } from "../Function.js"
|
|
6
|
-
import { globalValue } from "../GlobalValue.js"
|
|
7
|
-
import * as HashMap from "../HashMap.js"
|
|
8
|
-
import * as Inspectable from "../Inspectable.js"
|
|
9
|
-
import * as List from "../List.js"
|
|
10
|
-
import type * as Logger from "../Logger.js"
|
|
11
|
-
import type * as LogLevel from "../LogLevel.js"
|
|
12
|
-
import * as Option from "../Option.js"
|
|
13
|
-
import { pipeArguments } from "../Pipeable.js"
|
|
14
|
-
import * as Cause from "./cause.js"
|
|
15
|
-
import * as defaultServices from "./defaultServices.js"
|
|
16
|
-
import { consoleTag } from "./defaultServices/console.js"
|
|
17
|
-
import * as fiberId_ from "./fiberId.js"
|
|
18
|
-
import * as logSpan_ from "./logSpan.js"
|
|
19
|
-
|
|
20
|
-
/** @internal */
|
|
21
|
-
const LoggerSymbolKey = "effect/Logger"
|
|
22
|
-
|
|
23
|
-
/** @internal */
|
|
24
|
-
export const LoggerTypeId: Logger.LoggerTypeId = Symbol.for(
|
|
25
|
-
LoggerSymbolKey
|
|
26
|
-
) as Logger.LoggerTypeId
|
|
27
|
-
|
|
28
|
-
const loggerVariance = {
|
|
29
|
-
/* c8 ignore next */
|
|
30
|
-
_Message: (_: unknown) => _,
|
|
31
|
-
/* c8 ignore next */
|
|
32
|
-
_Output: (_: never) => _
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/** @internal */
|
|
36
|
-
export const makeLogger = <Message, Output>(
|
|
37
|
-
log: (options: Logger.Logger.Options<Message>) => Output
|
|
38
|
-
): Logger.Logger<Message, Output> => ({
|
|
39
|
-
[LoggerTypeId]: loggerVariance,
|
|
40
|
-
log,
|
|
41
|
-
pipe() {
|
|
42
|
-
return pipeArguments(this, arguments)
|
|
43
|
-
}
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
/** @internal */
|
|
47
|
-
export const mapInput = dual<
|
|
48
|
-
<Message, Message2>(
|
|
49
|
-
f: (message: Message2) => Message
|
|
50
|
-
) => <Output>(self: Logger.Logger<Message, Output>) => Logger.Logger<Message2, Output>,
|
|
51
|
-
<Output, Message, Message2>(
|
|
52
|
-
self: Logger.Logger<Message, Output>,
|
|
53
|
-
f: (message: Message2) => Message
|
|
54
|
-
) => Logger.Logger<Message2, Output>
|
|
55
|
-
>(2, (self, f) =>
|
|
56
|
-
makeLogger(
|
|
57
|
-
(options) => self.log({ ...options, message: f(options.message) })
|
|
58
|
-
))
|
|
59
|
-
|
|
60
|
-
/** @internal */
|
|
61
|
-
export const mapInputOptions = dual<
|
|
62
|
-
<Message, Message2>(
|
|
63
|
-
f: (options: Logger.Logger.Options<Message2>) => Logger.Logger.Options<Message>
|
|
64
|
-
) => <Output>(self: Logger.Logger<Message, Output>) => Logger.Logger<Message2, Output>,
|
|
65
|
-
<Output, Message, Message2>(
|
|
66
|
-
self: Logger.Logger<Message, Output>,
|
|
67
|
-
f: (options: Logger.Logger.Options<Message2>) => Logger.Logger.Options<Message>
|
|
68
|
-
) => Logger.Logger<Message2, Output>
|
|
69
|
-
>(2, (self, f) => makeLogger((options) => self.log(f(options))))
|
|
70
|
-
|
|
71
|
-
/** @internal */
|
|
72
|
-
export const filterLogLevel = dual<
|
|
73
|
-
(
|
|
74
|
-
f: (logLevel: LogLevel.LogLevel) => boolean
|
|
75
|
-
) => <Message, Output>(self: Logger.Logger<Message, Output>) => Logger.Logger<Message, Option.Option<Output>>,
|
|
76
|
-
<Message, Output>(
|
|
77
|
-
self: Logger.Logger<Message, Output>,
|
|
78
|
-
f: (logLevel: LogLevel.LogLevel) => boolean
|
|
79
|
-
) => Logger.Logger<Message, Option.Option<Output>>
|
|
80
|
-
>(2, (self, f) =>
|
|
81
|
-
makeLogger((options) =>
|
|
82
|
-
f(options.logLevel)
|
|
83
|
-
? Option.some(self.log(options))
|
|
84
|
-
: Option.none()
|
|
85
|
-
))
|
|
86
|
-
|
|
87
|
-
/** @internal */
|
|
88
|
-
export const map = dual<
|
|
89
|
-
<Output, Output2>(
|
|
90
|
-
f: (output: Output) => Output2
|
|
91
|
-
) => <Message>(self: Logger.Logger<Message, Output>) => Logger.Logger<Message, Output2>,
|
|
92
|
-
<Message, Output, Output2>(
|
|
93
|
-
self: Logger.Logger<Message, Output>,
|
|
94
|
-
f: (output: Output) => Output2
|
|
95
|
-
) => Logger.Logger<Message, Output2>
|
|
96
|
-
>(2, (self, f) => makeLogger((options) => f(self.log(options))))
|
|
97
|
-
|
|
98
|
-
/** @internal */
|
|
99
|
-
export const none: Logger.Logger<unknown, void> = {
|
|
100
|
-
[LoggerTypeId]: loggerVariance,
|
|
101
|
-
log: constVoid,
|
|
102
|
-
pipe() {
|
|
103
|
-
return pipeArguments(this, arguments)
|
|
104
|
-
}
|
|
105
|
-
} as Logger.Logger<unknown, void>
|
|
106
|
-
|
|
107
|
-
/** @internal */
|
|
108
|
-
export const simple = <A, B>(log: (a: A) => B): Logger.Logger<A, B> => ({
|
|
109
|
-
[LoggerTypeId]: loggerVariance,
|
|
110
|
-
log: ({ message }) => log(message),
|
|
111
|
-
pipe() {
|
|
112
|
-
return pipeArguments(this, arguments)
|
|
113
|
-
}
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
/** @internal */
|
|
117
|
-
export const succeed = <A>(value: A): Logger.Logger<unknown, A> => {
|
|
118
|
-
return simple(() => value)
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/** @internal */
|
|
122
|
-
export const sync = <A>(evaluate: LazyArg<A>): Logger.Logger<unknown, A> => {
|
|
123
|
-
return simple(evaluate)
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/** @internal */
|
|
127
|
-
export const zip = dual<
|
|
128
|
-
<Message2, Output2>(
|
|
129
|
-
that: Logger.Logger<Message2, Output2>
|
|
130
|
-
) => <Message, Output>(
|
|
131
|
-
self: Logger.Logger<Message, Output>
|
|
132
|
-
) => Logger.Logger<Message & Message2, [Output, Output2]>,
|
|
133
|
-
<Message, Output, Message2, Output2>(
|
|
134
|
-
self: Logger.Logger<Message, Output>,
|
|
135
|
-
that: Logger.Logger<Message2, Output2>
|
|
136
|
-
) => Logger.Logger<Message & Message2, [Output, Output2]>
|
|
137
|
-
>(2, (self, that) => makeLogger((options) => [self.log(options), that.log(options)]))
|
|
138
|
-
|
|
139
|
-
/** @internal */
|
|
140
|
-
export const zipLeft = dual<
|
|
141
|
-
<Message2, Output2>(
|
|
142
|
-
that: Logger.Logger<Message2, Output2>
|
|
143
|
-
) => <Message, Output>(
|
|
144
|
-
self: Logger.Logger<Message, Output>
|
|
145
|
-
) => Logger.Logger<Message & Message2, Output>,
|
|
146
|
-
<Message, Output, Message2, Output2>(
|
|
147
|
-
self: Logger.Logger<Message, Output>,
|
|
148
|
-
that: Logger.Logger<Message2, Output2>
|
|
149
|
-
) => Logger.Logger<Message & Message2, Output>
|
|
150
|
-
>(2, (self, that) => map(zip(self, that), (tuple) => tuple[0]))
|
|
151
|
-
|
|
152
|
-
/** @internal */
|
|
153
|
-
export const zipRight = dual<
|
|
154
|
-
<Message2, Output2>(
|
|
155
|
-
that: Logger.Logger<Message2, Output2>
|
|
156
|
-
) => <Message, Output>(
|
|
157
|
-
self: Logger.Logger<Message, Output>
|
|
158
|
-
) => Logger.Logger<Message & Message2, Output2>,
|
|
159
|
-
<Message, Output, Message2, Output2>(
|
|
160
|
-
self: Logger.Logger<Message, Output>,
|
|
161
|
-
that: Logger.Logger<Message2, Output2>
|
|
162
|
-
) => Logger.Logger<Message & Message2, Output2>
|
|
163
|
-
>(2, (self, that) => map(zip(self, that), (tuple) => tuple[1]))
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Match strings that do not contain any whitespace characters, double quotes,
|
|
167
|
-
* or equal signs.
|
|
168
|
-
*
|
|
169
|
-
* @internal
|
|
170
|
-
*/
|
|
171
|
-
const textOnly = /^[^\s"=]*$/
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Used by both {@link stringLogger} and {@link logfmtLogger} to render a log
|
|
175
|
-
* message.
|
|
176
|
-
*
|
|
177
|
-
* @internal
|
|
178
|
-
*/
|
|
179
|
-
const format = (quoteValue: (s: string) => string, whitespace?: number | string | undefined) =>
|
|
180
|
-
(
|
|
181
|
-
{ annotations, cause, date, fiberId, logLevel, message, spans }: Logger.Logger.Options<unknown>
|
|
182
|
-
): string => {
|
|
183
|
-
const formatValue = (value: string): string => value.match(textOnly) ? value : quoteValue(value)
|
|
184
|
-
const format = (label: string, value: string): string => `${logSpan_.formatLabel(label)}=${formatValue(value)}`
|
|
185
|
-
const append = (label: string, value: string): string => " " + format(label, value)
|
|
186
|
-
|
|
187
|
-
let out = format("timestamp", date.toISOString())
|
|
188
|
-
out += append("level", logLevel.label)
|
|
189
|
-
out += append("fiber", fiberId_.threadName(fiberId))
|
|
190
|
-
|
|
191
|
-
const messages = Arr.ensure(message)
|
|
192
|
-
for (let i = 0; i < messages.length; i++) {
|
|
193
|
-
out += append("message", Inspectable.toStringUnknown(messages[i], whitespace))
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
if (!Cause.isEmptyType(cause)) {
|
|
197
|
-
out += append("cause", Cause.pretty(cause, { renderErrorCause: true }))
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
for (const span of spans) {
|
|
201
|
-
out += " " + logSpan_.render(date.getTime())(span)
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
for (const [label, value] of annotations) {
|
|
205
|
-
out += append(label, Inspectable.toStringUnknown(value, whitespace))
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
return out
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/** @internal */
|
|
212
|
-
const escapeDoubleQuotes = (s: string) => `"${s.replace(/\\([\s\S])|(")/g, "\\$1$2")}"`
|
|
213
|
-
|
|
214
|
-
/** @internal */
|
|
215
|
-
export const stringLogger: Logger.Logger<unknown, string> = makeLogger(format(escapeDoubleQuotes))
|
|
216
|
-
|
|
217
|
-
/** @internal */
|
|
218
|
-
export const logfmtLogger: Logger.Logger<unknown, string> = makeLogger(format(JSON.stringify, 0))
|
|
219
|
-
|
|
220
|
-
/** @internal */
|
|
221
|
-
export const structuredLogger = makeLogger<unknown, {
|
|
222
|
-
readonly logLevel: string
|
|
223
|
-
readonly fiberId: string
|
|
224
|
-
readonly timestamp: string
|
|
225
|
-
readonly message: unknown
|
|
226
|
-
readonly cause: string | undefined
|
|
227
|
-
readonly annotations: Record<string, unknown>
|
|
228
|
-
readonly spans: Record<string, number>
|
|
229
|
-
}>(
|
|
230
|
-
({ annotations, cause, date, fiberId, logLevel, message, spans }) => {
|
|
231
|
-
const now = date.getTime()
|
|
232
|
-
const annotationsObj: Record<string, unknown> = {}
|
|
233
|
-
const spansObj: Record<string, number> = {}
|
|
234
|
-
|
|
235
|
-
if (HashMap.size(annotations) > 0) {
|
|
236
|
-
for (const [k, v] of annotations) {
|
|
237
|
-
annotationsObj[k] = structuredMessage(v)
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
if (List.isCons(spans)) {
|
|
242
|
-
for (const span of spans) {
|
|
243
|
-
spansObj[span.label] = now - span.startTime
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
const messageArr = Arr.ensure(message)
|
|
248
|
-
return {
|
|
249
|
-
message: messageArr.length === 1 ? structuredMessage(messageArr[0]) : messageArr.map(structuredMessage),
|
|
250
|
-
logLevel: logLevel.label,
|
|
251
|
-
timestamp: date.toISOString(),
|
|
252
|
-
cause: Cause.isEmpty(cause) ? undefined : Cause.pretty(cause, { renderErrorCause: true }),
|
|
253
|
-
annotations: annotationsObj,
|
|
254
|
-
spans: spansObj,
|
|
255
|
-
fiberId: fiberId_.threadName(fiberId)
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
)
|
|
259
|
-
|
|
260
|
-
/** @internal */
|
|
261
|
-
export const structuredMessage = (u: unknown): unknown => {
|
|
262
|
-
switch (typeof u) {
|
|
263
|
-
case "bigint":
|
|
264
|
-
case "function":
|
|
265
|
-
case "symbol": {
|
|
266
|
-
return String(u)
|
|
267
|
-
}
|
|
268
|
-
default: {
|
|
269
|
-
return Inspectable.toJSON(u)
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
/** @internal */
|
|
275
|
-
export const jsonLogger = map(structuredLogger, Inspectable.stringifyCircular)
|
|
276
|
-
|
|
277
|
-
/** @internal */
|
|
278
|
-
export const isLogger = (u: unknown): u is Logger.Logger<unknown, unknown> => {
|
|
279
|
-
return typeof u === "object" && u != null && LoggerTypeId in u
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
const withColor = (text: string, ...colors: ReadonlyArray<string>) => {
|
|
283
|
-
let out = ""
|
|
284
|
-
for (let i = 0; i < colors.length; i++) {
|
|
285
|
-
out += `\x1b[${colors[i]}m`
|
|
286
|
-
}
|
|
287
|
-
return out + text + "\x1b[0m"
|
|
288
|
-
}
|
|
289
|
-
const withColorNoop = (text: string, ..._colors: ReadonlyArray<string>) => text
|
|
290
|
-
const colors = {
|
|
291
|
-
bold: "1",
|
|
292
|
-
red: "31",
|
|
293
|
-
green: "32",
|
|
294
|
-
yellow: "33",
|
|
295
|
-
blue: "34",
|
|
296
|
-
cyan: "36",
|
|
297
|
-
white: "37",
|
|
298
|
-
gray: "90",
|
|
299
|
-
black: "30",
|
|
300
|
-
bgBrightRed: "101"
|
|
301
|
-
} as const
|
|
302
|
-
|
|
303
|
-
const logLevelColors: Record<LogLevel.LogLevel["_tag"], ReadonlyArray<string>> = {
|
|
304
|
-
None: [],
|
|
305
|
-
All: [],
|
|
306
|
-
Trace: [colors.gray],
|
|
307
|
-
Debug: [colors.blue],
|
|
308
|
-
Info: [colors.green],
|
|
309
|
-
Warning: [colors.yellow],
|
|
310
|
-
Error: [colors.red],
|
|
311
|
-
Fatal: [colors.bgBrightRed, colors.black]
|
|
312
|
-
}
|
|
313
|
-
const logLevelStyle: Record<LogLevel.LogLevel["_tag"], string> = {
|
|
314
|
-
None: "",
|
|
315
|
-
All: "",
|
|
316
|
-
Trace: "color:gray",
|
|
317
|
-
Debug: "color:blue",
|
|
318
|
-
Info: "color:green",
|
|
319
|
-
Warning: "color:orange",
|
|
320
|
-
Error: "color:red",
|
|
321
|
-
Fatal: "background-color:red;color:white"
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
const defaultDateFormat = (date: Date): string =>
|
|
325
|
-
`${date.getHours().toString().padStart(2, "0")}:${date.getMinutes().toString().padStart(2, "0")}:${
|
|
326
|
-
date.getSeconds().toString().padStart(2, "0")
|
|
327
|
-
}.${date.getMilliseconds().toString().padStart(3, "0")}`
|
|
328
|
-
|
|
329
|
-
const hasProcessStdout = typeof process === "object" &&
|
|
330
|
-
process !== null &&
|
|
331
|
-
typeof process.stdout === "object" &&
|
|
332
|
-
process.stdout !== null
|
|
333
|
-
const processStdoutIsTTY = hasProcessStdout &&
|
|
334
|
-
process.stdout.isTTY === true
|
|
335
|
-
const hasProcessStdoutOrDeno = hasProcessStdout || "Deno" in globalThis
|
|
336
|
-
|
|
337
|
-
/** @internal */
|
|
338
|
-
export const prettyLogger = (options?: {
|
|
339
|
-
readonly colors?: "auto" | boolean | undefined
|
|
340
|
-
readonly stderr?: boolean | undefined
|
|
341
|
-
readonly formatDate?: ((date: Date) => string) | undefined
|
|
342
|
-
readonly mode?: "browser" | "tty" | "auto" | undefined
|
|
343
|
-
}) => {
|
|
344
|
-
const mode_ = options?.mode ?? "auto"
|
|
345
|
-
const mode = mode_ === "auto" ? (hasProcessStdoutOrDeno ? "tty" : "browser") : mode_
|
|
346
|
-
const isBrowser = mode === "browser"
|
|
347
|
-
const showColors = typeof options?.colors === "boolean" ? options.colors : processStdoutIsTTY || isBrowser
|
|
348
|
-
const formatDate = options?.formatDate ?? defaultDateFormat
|
|
349
|
-
return isBrowser
|
|
350
|
-
? prettyLoggerBrowser({ colors: showColors, formatDate })
|
|
351
|
-
: prettyLoggerTty({ colors: showColors, formatDate, stderr: options?.stderr === true })
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
const prettyLoggerTty = (options: {
|
|
355
|
-
readonly colors: boolean
|
|
356
|
-
readonly stderr: boolean
|
|
357
|
-
readonly formatDate: (date: Date) => string
|
|
358
|
-
}) => {
|
|
359
|
-
const color = options.colors ? withColor : withColorNoop
|
|
360
|
-
return makeLogger<unknown, void>(
|
|
361
|
-
({ annotations, cause, context, date, fiberId, logLevel, message: message_, spans }) => {
|
|
362
|
-
const services = FiberRefs.getOrDefault(context, defaultServices.currentServices)
|
|
363
|
-
const console = Context.get(services, consoleTag).unsafe
|
|
364
|
-
const log = options.stderr === true ? console.error : console.log
|
|
365
|
-
|
|
366
|
-
const message = Arr.ensure(message_)
|
|
367
|
-
|
|
368
|
-
let firstLine = color(`[${options.formatDate(date)}]`, colors.white)
|
|
369
|
-
+ ` ${color(logLevel.label, ...logLevelColors[logLevel._tag])}`
|
|
370
|
-
+ ` (${fiberId_.threadName(fiberId)})`
|
|
371
|
-
|
|
372
|
-
if (List.isCons(spans)) {
|
|
373
|
-
const now = date.getTime()
|
|
374
|
-
const render = logSpan_.render(now)
|
|
375
|
-
for (const span of spans) {
|
|
376
|
-
firstLine += " " + render(span)
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
firstLine += ":"
|
|
381
|
-
let messageIndex = 0
|
|
382
|
-
if (message.length > 0) {
|
|
383
|
-
const firstMaybeString = structuredMessage(message[0])
|
|
384
|
-
if (typeof firstMaybeString === "string") {
|
|
385
|
-
firstLine += " " + color(firstMaybeString, colors.bold, colors.cyan)
|
|
386
|
-
messageIndex++
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
log(firstLine)
|
|
391
|
-
console.group()
|
|
392
|
-
|
|
393
|
-
if (!Cause.isEmpty(cause)) {
|
|
394
|
-
log(Cause.pretty(cause, { renderErrorCause: true }))
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
if (messageIndex < message.length) {
|
|
398
|
-
for (; messageIndex < message.length; messageIndex++) {
|
|
399
|
-
log(Inspectable.redact(message[messageIndex]))
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
if (HashMap.size(annotations) > 0) {
|
|
404
|
-
for (const [key, value] of annotations) {
|
|
405
|
-
log(color(`${key}:`, colors.bold, colors.white), Inspectable.redact(value))
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
console.groupEnd()
|
|
410
|
-
}
|
|
411
|
-
)
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
const prettyLoggerBrowser = (options: {
|
|
415
|
-
readonly colors: boolean
|
|
416
|
-
readonly formatDate: (date: Date) => string
|
|
417
|
-
}) => {
|
|
418
|
-
const color = options.colors ? "%c" : ""
|
|
419
|
-
return makeLogger<unknown, void>(
|
|
420
|
-
({ annotations, cause, context, date, fiberId, logLevel, message: message_, spans }) => {
|
|
421
|
-
const services = FiberRefs.getOrDefault(context, defaultServices.currentServices)
|
|
422
|
-
const console = Context.get(services, consoleTag).unsafe
|
|
423
|
-
const message = Arr.ensure(message_)
|
|
424
|
-
|
|
425
|
-
let firstLine = `${color}[${options.formatDate(date)}]`
|
|
426
|
-
const firstParams = []
|
|
427
|
-
if (options.colors) {
|
|
428
|
-
firstParams.push("color:gray")
|
|
429
|
-
}
|
|
430
|
-
firstLine += ` ${color}${logLevel.label}${color} (${fiberId_.threadName(fiberId)})`
|
|
431
|
-
if (options.colors) {
|
|
432
|
-
firstParams.push(logLevelStyle[logLevel._tag], "")
|
|
433
|
-
}
|
|
434
|
-
if (List.isCons(spans)) {
|
|
435
|
-
const now = date.getTime()
|
|
436
|
-
const render = logSpan_.render(now)
|
|
437
|
-
for (const span of spans) {
|
|
438
|
-
firstLine += " " + render(span)
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
firstLine += ":"
|
|
443
|
-
|
|
444
|
-
let messageIndex = 0
|
|
445
|
-
if (message.length > 0) {
|
|
446
|
-
const firstMaybeString = structuredMessage(message[0])
|
|
447
|
-
if (typeof firstMaybeString === "string") {
|
|
448
|
-
firstLine += ` ${color}${firstMaybeString}`
|
|
449
|
-
if (options.colors) {
|
|
450
|
-
firstParams.push("color:deepskyblue")
|
|
451
|
-
}
|
|
452
|
-
messageIndex++
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
console.groupCollapsed(firstLine, ...firstParams)
|
|
457
|
-
|
|
458
|
-
if (!Cause.isEmpty(cause)) {
|
|
459
|
-
console.error(Cause.pretty(cause, { renderErrorCause: true }))
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
if (messageIndex < message.length) {
|
|
463
|
-
for (; messageIndex < message.length; messageIndex++) {
|
|
464
|
-
console.log(Inspectable.redact(message[messageIndex]))
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
if (HashMap.size(annotations) > 0) {
|
|
469
|
-
for (const [key, value] of annotations) {
|
|
470
|
-
const redacted = Inspectable.redact(value)
|
|
471
|
-
if (options.colors) {
|
|
472
|
-
console.log(`%c${key}:`, "color:gray", redacted)
|
|
473
|
-
} else {
|
|
474
|
-
console.log(`${key}:`, redacted)
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
console.groupEnd()
|
|
480
|
-
}
|
|
481
|
-
)
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
/** @internal */
|
|
485
|
-
export const prettyLoggerDefault = globalValue("effect/Logger/prettyLoggerDefault", () => prettyLogger())
|