Skip to content

Instantly share code, notes, and snippets.

@adamauckland
Created March 21, 2017 07:02
Show Gist options
  • Select an option

  • Save adamauckland/6c991c0b19a4420df8574c0b208f26d8 to your computer and use it in GitHub Desktop.

Select an option

Save adamauckland/6c991c0b19a4420df8574c0b208f26d8 to your computer and use it in GitHub Desktop.

Revisions

  1. adamauckland created this gist Mar 21, 2017.
    45 changes: 45 additions & 0 deletions index.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,45 @@
    // 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();