Created
March 30, 2016 08:35
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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