X-Git-Url: http://git.squeep.com/?p=squeep-amqp-helper;a=blobdiff_plain;f=lib%2Fcommon.js;fp=lib%2Fcommon.js;h=68b7b5e971026afe5900f35f7e83dd3a86f45bcf;hp=0000000000000000000000000000000000000000;hb=174280d3f44ba13dac0b26d42d968189a4f4fa93;hpb=67905316ada5ee4668306506705f4ee2a5f407f0 diff --git a/lib/common.js b/lib/common.js new file mode 100644 index 0000000..68b7b5e --- /dev/null +++ b/lib/common.js @@ -0,0 +1,19 @@ +'use strict'; +const path = require('path'); +const { name: packageName, version: packageVersion } = require('../package'); + +const libraryIdentifier = `${packageName}@${packageVersion}`; + +/** + * Return a function for decorating logging method scopes. + * @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(':'); +}; + +module.exports = { + fileScope, +}; \ No newline at end of file