Skip to content

Instantly share code, notes, and snippets.

@adamauckland
Created March 21, 2017 07:02
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 adamauckland/6c991c0b19a4420df8574c0b208f26d8 to your computer and use it in GitHub Desktop.
Save adamauckland/6c991c0b19a4420df8574c0b208f26d8 to your computer and use it in GitHub Desktop.
Testing renaming classes
// 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