use log-helper fileScope
[squeep-indieauth-helper] / lib / common.js
index c1b8703d58d435a127a80fcfaec70b73358a2a2c..7a918bb9f4eaf1d7b588152d35290268ced89aa5 100644 (file)
@@ -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
+};