Created
March 21, 2017 07:02
-
-
Save adamauckland/6c991c0b19a4420df8574c0b208f26d8 to your computer and use it in GitHub Desktop.
Testing renaming classes
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
// Requires Node V8 | |
// | |
// Put this script in a directory, then do: | |
// | |
// $ npm init | |
// $ npm install cornerstonelabs-semantic-logging --save | |
// $ node index.js --harmony | |
// | |
// | |
// | |
// Import Semantic Logger ( https://github.com/CornerstoneLabs/semantic-logging ) | |
// | |
var semanticLogging = require("cornerstonelabs-semantic-logging"); | |
// | |
// create a dummy class which implements the logging | |
// | |
class DummyClass extends semanticLogging.SemanticLogger { | |
constructor (request) { | |
super (request); | |
} | |
@info | |
initialising () {}; | |
@info | |
started () {}; | |
@error | |
startFailed () {}; | |
} | |
// | |
// Rename the class to SpecialLogger | |
// | |
Object.defineProperty(DummyClass, "name", "SpecialLogger"); | |
// | |
// SemanticLogger logs the target.constructor.name in the decorator, so this should log as SpecialLogger. | |
// | |
var logger = new SpecialLogger(); | |
logger.info(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment