Skip to content

Instantly share code, notes, and snippets.

@leegee
Created March 30, 2016 08:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leegee/143ce2bc97869027983fb71561a38e8c to your computer and use it in GitHub Desktop.
Save leegee/143ce2bc97869027983fb71561a38e8c to your computer and use it in GitHub Desktop.
Init a log4js logger with category auto-set to 'module' name, via base prototype.
module.exports = Base;
function Base(category) {
try {
category = category || new Error().stack.match(/Base\.(\w+)/)[1];
}
finally {
if (!category) {
throw new Error('Base requires its sub-class to supply a logging-category argument! ');
}
}
this.logger = require('./log4js').getLogger( category );
}
const Base = require('./base.js');
/* @constructor */
function ASubClass() {
Base.call(this);
}
/* @augments Base */
TestFramework.prototype = Object.create(Base.prototype);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment