0.0.20 • Published 9 years ago

cornerstonelabs-semantic-logging v0.0.20

Weekly downloads
57
License
-
Repository
-
Last release
9 years ago

Build Status

Semantic Logging for NodeJS.

Strongly typed logging.

Current adapters:

  • Console

  • Winston

Usage:

Install the library:

npm install cornerstonelabs-semantic-logging --save

Import it:

var semanticLogging = require("cornerstonelabs-semantic-logging");

The interesting class is semanticLogging.SemanticLogger.

You have five decorators/attributes to define the log level:

semanticLogging.debug, semanticLogging.verbose, semanticLogging.info, semanticLogging.warn, semanticLogging.error

This is the bit you need to do:

Subclass SemanticLogger and add functions for each log message.

Decorate the functions with the log level. The following log levels are supported: @debug @verbose @info @warn @error

Example:

var semanticLogging = require("cornerstonelabs-semantic-logging");

var debug = semanticLogging.debug;
var verbose = semanticLogging.verbose;
var info = semanticLogging.info;
var warn = semanticLogging.warn;
var error = semanticLogging.error;

class DoingSomethingLogging extends semanticLogging.SemanticLogger {
    constructor (request) {
        super (request);
    }

    @info
    initialising () {};

    @info
    started () {};

    @error
    startFailed () {};
}


// now let's do some logging:

function startDoingSomething () {
    var logger = new DoingSomethingLogging();
    logger.initialising();

    logger.started();

    if (err) {
        logger.startFailed(err);
    }
}

You can pass any number of parameters into the log function and they will be added to the log message.

0.0.20

9 years ago

0.0.18

9 years ago

0.0.17

9 years ago

0.0.16

9 years ago

0.0.15

9 years ago

0.0.14

9 years ago

0.0.13

9 years ago

0.0.12

9 years ago

0.0.11

9 years ago

0.0.10

9 years ago

0.0.9

9 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago