functype-log 0.2.0 → 0.60.5
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.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{IO as e}from"functype";const t=(t,n,r)=>(i,a)=>e.sync(()=>{let e=a?t.withMetadata(a):t;r
|
|
1
|
+
import{IO as e}from"functype";const t=(t,n,r)=>(i,a)=>e.sync(()=>{let e=a?t.withMetadata(a):t;(r?e.withError(r):e)[n](i)}),n=(e,r)=>({trace:t(e,`trace`,r),debug:t(e,`debug`,r),info:t(e,`info`,r),warn:t(e,`warn`,r),error:t(e,`error`,r),fatal:t(e,`fatal`,r),withError:t=>n(e,t),withContext:t=>n(e.withContext(t),r),child:t=>{let r=e.child();return n(t?r.withContext(t):r)}});export{n as logLayerAdapter};
|
|
2
2
|
//# sourceMappingURL=LogLayerAdapter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogLayerAdapter.js","names":[],"sources":["../../src/adapter/LogLayerAdapter.ts"],"sourcesContent":["import { IO } from \"functype\"\nimport type { ILogLayer } from \"loglayer\"\n\nimport type { Logger, LogLevel, LogMetadata } from \"../logger/Logger\"\n\nconst makeMethod =\n (logLayer: ILogLayer, level: LogLevel, baseError?: Error) =>\n (message: string, metadata?: LogMetadata): IO<never, never, void> =>\n IO.sync(() => {\n
|
|
1
|
+
{"version":3,"file":"LogLayerAdapter.js","names":[],"sources":["../../src/adapter/LogLayerAdapter.ts"],"sourcesContent":["import { IO } from \"functype\"\nimport type { ILogLayer } from \"loglayer\"\n\nimport type { Logger, LogLevel, LogMetadata } from \"../logger/Logger\"\n\nconst makeMethod =\n (logLayer: ILogLayer, level: LogLevel, baseError?: Error) =>\n (message: string, metadata?: LogMetadata): IO<never, never, void> =>\n IO.sync(() => {\n const base = metadata ? logLayer.withMetadata(metadata) : logLayer\n const entry = baseError ? base.withError(baseError) : base\n entry[level](message)\n })\n\nexport const logLayerAdapter = (logLayer: ILogLayer, baseError?: Error): Logger => ({\n trace: makeMethod(logLayer, \"trace\", baseError),\n debug: makeMethod(logLayer, \"debug\", baseError),\n info: makeMethod(logLayer, \"info\", baseError),\n warn: makeMethod(logLayer, \"warn\", baseError),\n error: makeMethod(logLayer, \"error\", baseError),\n fatal: makeMethod(logLayer, \"fatal\", baseError),\n withError: (err: Error) => logLayerAdapter(logLayer, err),\n withContext: (ctx: LogMetadata) => logLayerAdapter(logLayer.withContext(ctx), baseError),\n child: (ctx?: LogMetadata) => {\n const childLog = logLayer.child()\n return ctx ? logLayerAdapter(childLog.withContext(ctx)) : logLayerAdapter(childLog)\n },\n})\n"],"mappings":"8BAKA,MAAM,GACH,EAAqB,EAAiB,KACtC,EAAiB,IAChB,EAAG,SAAW,CACZ,IAAM,EAAO,EAAW,EAAS,aAAa,EAAS,CAAG,GAC5C,EAAY,EAAK,UAAU,EAAU,CAAG,GAChD,GAAO,EAAQ,EACrB,CAEO,GAAmB,EAAqB,KAA+B,CAClF,MAAO,EAAW,EAAU,QAAS,EAAU,CAC/C,MAAO,EAAW,EAAU,QAAS,EAAU,CAC/C,KAAM,EAAW,EAAU,OAAQ,EAAU,CAC7C,KAAM,EAAW,EAAU,OAAQ,EAAU,CAC7C,MAAO,EAAW,EAAU,QAAS,EAAU,CAC/C,MAAO,EAAW,EAAU,QAAS,EAAU,CAC/C,UAAY,GAAe,EAAgB,EAAU,EAAI,CACzD,YAAc,GAAqB,EAAgB,EAAS,YAAY,EAAI,CAAE,EAAU,CACxF,MAAQ,GAAsB,CAC5B,IAAM,EAAW,EAAS,OAAO,CACjC,OAAa,EAAN,EAAsB,EAAS,YAAY,EAAI,CAAoB,EAAS,EAEtF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConsoleLogger.js","names":[],"sources":["../../src/layers/ConsoleLogger.ts"],"sourcesContent":["import { ConsoleTransport, LogLayer } from \"loglayer\"\n\nimport { logLayerAdapter } from \"../adapter/LogLayerAdapter\"\nimport type { Logger, LogLevel } from \"../logger/Logger\"\n\nexport type ConsoleLoggerOptions = {\n readonly level?: LogLevel\n readonly prefix?: string\n}\n\nexport const createConsoleLogger = (options?: ConsoleLoggerOptions): Logger => {\n const logLayer = new LogLayer({\n transport: new ConsoleTransport({ logger: console }),\n ...(options?.prefix ? { prefix: options.prefix } : {}),\n })\n\n return logLayerAdapter(logLayer)\n}\n"],"mappings":"0HAUA,MAAa,EAAuB,GAM3B,
|
|
1
|
+
{"version":3,"file":"ConsoleLogger.js","names":[],"sources":["../../src/layers/ConsoleLogger.ts"],"sourcesContent":["import { ConsoleTransport, LogLayer } from \"loglayer\"\n\nimport { logLayerAdapter } from \"../adapter/LogLayerAdapter\"\nimport type { Logger, LogLevel } from \"../logger/Logger\"\n\nexport type ConsoleLoggerOptions = {\n readonly level?: LogLevel\n readonly prefix?: string\n}\n\nexport const createConsoleLogger = (options?: ConsoleLoggerOptions): Logger => {\n const logLayer = new LogLayer({\n transport: new ConsoleTransport({ logger: console }),\n ...(options?.prefix ? { prefix: options.prefix } : {}),\n })\n\n return logLayerAdapter(logLayer)\n}\n"],"mappings":"0HAUA,MAAa,EAAuB,GAM3B,EAAgB,IALF,EAAS,CAC5B,UAAW,IAAI,EAAiB,CAAE,OAAQ,QAAS,CAAC,CACpD,GAAI,GAAS,OAAS,CAAE,OAAQ,EAAQ,OAAQ,CAAG,EAAE,CACtD,CAE8B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogMiddleware.js","names":["IOImpl","LoggerTag"],"sources":["../../src/middleware/LogMiddleware.ts"],"sourcesContent":["import type { IO } from \"functype\"\nimport { IO as IOImpl } from \"functype\"\n\nimport type { Logger, LogLevel } from \"../logger/Logger\"\nimport { Logger as LoggerTag } from \"../logger/Logger\"\n\n/** Wrap any IO with start/complete/error logging at debug level */\nexport const withLogging = <R, E, A>(name: string, effect: IO<R, E, A>): IO<R | Logger, E, A> =>\n IOImpl.gen(function* () {\n const log = yield* IOImpl.service(LoggerTag)\n yield* log.debug(`${name}: starting`)\n const result = yield* effect\n yield* log.debug(`${name}: completed`)\n return result\n }) as IO<R | Logger, E, A>\n\n/** Create a tap function that logs at the specified level */\nexport const tapLog =\n <A>(level: LogLevel, message: string | ((a: A) => string)) =>\n <R, E>(effect: IO<R, E, A>): IO<R | Logger, E, A> =>\n IOImpl.gen(function* () {\n const result = yield* effect\n const log = yield* IOImpl.service(LoggerTag)\n const msg = typeof message === \"string\" ? message : message(result)\n yield* log[level](msg)\n return result\n }) as IO<R | Logger, E, A>\n"],"mappings":"2EAOA,MAAa,GAAwB,EAAc,IACjDA,EAAO,IAAI,WAAa,CACtB,IAAM,EAAM,MAAOA,EAAO,QAAQC,EAAU,CAC5C,MAAO,EAAI,MAAM,GAAG,EAAK,YAAY,CACrC,IAAM,EAAS,MAAO,EAEtB,OADA,MAAO,EAAI,MAAM,GAAG,EAAK,aAAa,CAC/B,GACP,CAGS,GACP,EAAiB,IACd,GACLD,EAAO,IAAI,WAAa,CACtB,IAAM,EAAS,MAAO,EAChB,EAAM,MAAOA,EAAO,QAAQC,EAAU,CACtC,EAAM,OAAO,GAAY,SAAW,EAAU,EAAQ,EAAO,CAEnE,OADA,MAAO,EAAI,GAAO,EAAI,CACf,GACP"}
|
|
1
|
+
{"version":3,"file":"LogMiddleware.js","names":["IOImpl","LoggerTag"],"sources":["../../src/middleware/LogMiddleware.ts"],"sourcesContent":["import type { IO } from \"functype\"\nimport { IO as IOImpl } from \"functype\"\n\nimport type { Logger, LogLevel } from \"../logger/Logger\"\nimport { Logger as LoggerTag } from \"../logger/Logger\"\n\n/** Wrap any IO with start/complete/error logging at debug level */\nexport const withLogging = <R, E, A>(name: string, effect: IO<R, E, A>): IO<R | Logger, E, A> =>\n IOImpl.gen(function* () {\n const log = yield* IOImpl.service(LoggerTag)\n yield* log.debug(`${name}: starting`)\n const result = yield* effect\n yield* log.debug(`${name}: completed`)\n return result\n }) as unknown as IO<R | Logger, E, A>\n\n/** Create a tap function that logs at the specified level */\nexport const tapLog =\n <A>(level: LogLevel, message: string | ((a: A) => string)) =>\n <R, E>(effect: IO<R, E, A>): IO<R | Logger, E, A> =>\n IOImpl.gen(function* () {\n const result = yield* effect\n const log = yield* IOImpl.service(LoggerTag)\n const msg = typeof message === \"string\" ? message : message(result)\n yield* log[level](msg)\n return result\n }) as unknown as IO<R | Logger, E, A>\n"],"mappings":"2EAOA,MAAa,GAAwB,EAAc,IACjDA,EAAO,IAAI,WAAa,CACtB,IAAM,EAAM,MAAOA,EAAO,QAAQC,EAAU,CAC5C,MAAO,EAAI,MAAM,GAAG,EAAK,YAAY,CACrC,IAAM,EAAS,MAAO,EAEtB,OADA,MAAO,EAAI,MAAM,GAAG,EAAK,aAAa,CAC/B,GACP,CAGS,GACP,EAAiB,IACd,GACLD,EAAO,IAAI,WAAa,CACtB,IAAM,EAAS,MAAO,EAChB,EAAM,MAAOA,EAAO,QAAQC,EAAU,CACtC,EAAM,OAAO,GAAY,SAAW,EAAU,EAAQ,EAAO,CAEnE,OADA,MAAO,EAAI,GAAO,EAAI,CACf,GACP"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "functype-log",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.60.5",
|
|
4
4
|
"description": "IO-native logging for functype — wraps LogLayer with Tag/Layer DI, structured logging, and test utilities",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"functype",
|
|
@@ -13,22 +13,23 @@
|
|
|
13
13
|
],
|
|
14
14
|
"author": "jordan.burke@gmail.com",
|
|
15
15
|
"license": "MIT",
|
|
16
|
-
"homepage": "https://github.com/jordanburke/functype-log",
|
|
16
|
+
"homepage": "https://github.com/jordanburke/functype/tree/main/packages/functype-log",
|
|
17
17
|
"repository": {
|
|
18
18
|
"type": "git",
|
|
19
|
-
"url": "https://github.com/jordanburke/functype
|
|
19
|
+
"url": "https://github.com/jordanburke/functype",
|
|
20
|
+
"directory": "packages/functype-log"
|
|
20
21
|
},
|
|
21
22
|
"peerDependencies": {
|
|
22
|
-
"functype": "
|
|
23
|
+
"functype": "^0.60.5"
|
|
23
24
|
},
|
|
24
25
|
"dependencies": {
|
|
25
26
|
"loglayer": "^9.1.0"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
|
-
"@types/node": "^24.12.
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
29
|
+
"@types/node": "^24.12.2",
|
|
30
|
+
"ts-builds": "^2.8.0",
|
|
31
|
+
"tsdown": "^0.22.0",
|
|
32
|
+
"functype": "^0.60.5"
|
|
32
33
|
},
|
|
33
34
|
"type": "module",
|
|
34
35
|
"main": "./dist/index.js",
|
|
@@ -74,6 +75,10 @@
|
|
|
74
75
|
"engines": {
|
|
75
76
|
"node": ">=18.17.0"
|
|
76
77
|
},
|
|
78
|
+
"publishConfig": {
|
|
79
|
+
"access": "public",
|
|
80
|
+
"provenance": true
|
|
81
|
+
},
|
|
77
82
|
"scripts": {
|
|
78
83
|
"validate": "ts-builds validate",
|
|
79
84
|
"format": "ts-builds format",
|