X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=lib%2Fcommon.js;h=7a918bb9f4eaf1d7b588152d35290268ced89aa5;hb=ddf28d2e4816d7c4e188f8dd510b48ad87aee478;hp=c1b8703d58d435a127a80fcfaec70b73358a2a2c;hpb=cc52f66ba8522b6bc7002dfba79c1162a51aef0e;p=squeep-indieauth-helper diff --git a/lib/common.js b/lib/common.js index c1b8703..7a918bb 100644 --- a/lib/common.js +++ b/lib/common.js @@ -1,21 +1,5 @@ 'use strict'; -const path = require('path'); -const { name: packageName, version: packageVersion } = require('../package'); - -const libraryIdentifier = `${packageName}@${packageVersion}`; - -/** - * Return a function which combines a part of the filename with a scope, for use in logging. - * @param {string} filename - */ -const fileScope = (filename) => { - const shortFilename = path.basename(filename, '.js'); - const fScope = (shortFilename === 'index') ? path.basename(path.dirname(filename)) : shortFilename; - return (scope) => [libraryIdentifier, fScope, scope].join(':'); -} - - /** * Pick out useful got response fields. * @param {GotResponse} res @@ -27,6 +11,7 @@ const gotResponseLogData = (res) => { 'statusMessage', 'headers', 'body', + 'error', ]); if (typeof res.body === 'string') { data.body = logTruncate(data.body, 100); @@ -107,10 +92,9 @@ const properURLComponentName = (component) => { module.exports = { - fileScope, gotResponseLogData, logTruncate, pick, setSymmetricDifference, properURLComponentName, -}; \ No newline at end of file +};