@composite-fetcher/with-logging
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -37,4 +37,5 @@ // src/withLogging.ts | ||
logger; | ||
constructor(logger) { | ||
constructor(options = {}) { | ||
super(); | ||
const { logger } = options; | ||
this.logger = logger || new ConsoleLogger(); | ||
@@ -55,3 +56,2 @@ } | ||
this.logger.info(`Outgoing request to: ${context.request.url}`, logContext); | ||
context.next(); | ||
} | ||
@@ -75,3 +75,2 @@ async onPostRequest(context) { | ||
); | ||
context.next(); | ||
} | ||
@@ -78,0 +77,0 @@ }; |
@@ -13,6 +13,9 @@ import { BasePlugin, PluginHandlerContext, PluginLifecycleHook } from '@composite-fetcher/core'; | ||
} | ||
interface withLoggingOptions { | ||
logger?: Logger; | ||
} | ||
declare class withLoggingPlugin extends BasePlugin { | ||
private logger; | ||
constructor(logger?: Logger); | ||
constructor(options?: withLoggingOptions); | ||
onPreRequest(context: PluginHandlerContext<PluginLifecycleHook.PRE_REQUEST>): Promise<void>; | ||
@@ -22,2 +25,2 @@ onPostRequest(context: PluginHandlerContext<PluginLifecycleHook.POST_REQUEST>): Promise<void>; | ||
export { Logger, withLoggingPlugin as withLogging }; | ||
export { Logger, withLoggingPlugin as withLogging, withLoggingOptions }; |
@@ -37,4 +37,5 @@ // src/withLogging.ts | ||
logger; | ||
constructor(logger) { | ||
constructor(options = {}) { | ||
super(); | ||
const { logger } = options; | ||
this.logger = logger || new ConsoleLogger(); | ||
@@ -55,3 +56,2 @@ } | ||
this.logger.info(`Outgoing request to: ${context.request.url}`, logContext); | ||
context.next(); | ||
} | ||
@@ -75,3 +75,2 @@ async onPostRequest(context) { | ||
); | ||
context.next(); | ||
} | ||
@@ -78,0 +77,0 @@ }; |
{ | ||
"name": "@composite-fetcher/with-logging", | ||
"description": "A simple logging plugin for composite fetcher", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"author": "Teofanis Papadopulos", | ||
@@ -29,6 +29,6 @@ "type": "module", | ||
"dependencies": { | ||
"@composite-fetcher/core": "^0.1.4" | ||
"@composite-fetcher/core": "^0.1.5" | ||
}, | ||
"peerDependencies": { | ||
"@composite-fetcher/core": "^0.1.4" | ||
"@composite-fetcher/core": "^0.1.5" | ||
}, | ||
@@ -35,0 +35,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
11559