initial commit
[squeep-amqp-helper] / lib / common.js
1 'use strict';
2 const path = require('path');
3 const { name: packageName, version: packageVersion } = require('../package');
4
5 const libraryIdentifier = `${packageName}@${packageVersion}`;
6
7 /**
8 * Return a function for decorating logging method scopes.
9 * @param {String} filename
10 */
11 const fileScope = (filename) => {
12 const shortFilename = path.basename(filename, '.js');
13 const fScope = (shortFilename === 'index') ? path.basename(path.dirname(filename)) : shortFilename;
14 return (scope) => [libraryIdentifier, fScope, scope].join(':');
15 };
16
17 module.exports = {
18 fileScope,
19 };