Skip to content

Commit

Permalink
feat: use a external logger
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Jul 5, 2022
1 parent c51f813 commit df20890
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,13 @@ Default: `JSON.stringify`

Set the serializer method to be used before compress.

##### logger

Type: `function`<br/>
Default: `() => {}`

When it's present, every time cacheable-response is called, a log will be printed.

##### deserialize

Type: `function`<br/>
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"@keyvhq/core": "~1.6.0",
"@keyvhq/memoize": "~1.6.0",
"compress-brotli": "~1.3.3",
"debug-logfmt": "~1.0.4",
"etag": "~1.8.1",
"pretty-ms": "~7.0.1"
},
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict'

const debug = require('debug-logfmt')('cacheable-response')
const createCompress = require('compress-brotli')
const memoize = require('@keyvhq/memoize')
const Keyv = require('@keyvhq/core')
Expand All @@ -10,6 +9,7 @@ const getEtag = require('etag')
const { createKey, isFunction, setHeaders, size } = require('./util')

const cacheableResponse = ({
logger = () => {},
bypassQueryParameter = 'force',
cache = new Keyv({ namespace: 'ssr' }),
compress: enableCompression = false,
Expand Down Expand Up @@ -67,7 +67,7 @@ const cacheableResponse = ({
const ifNoneMatch = req.headers['if-none-match']
const isModified = etag !== ifNoneMatch

debug({
logger({
key,
isHit,
isExpired,
Expand Down

0 comments on commit df20890

Please sign in to comment.