index.js
function (opt) {
    if (typeof opt !== "object" || opt === null) {
        opt = {};
    }
    if (typeof opt.tag !== "string") {
        opt.tag = null;
    }
    if (typeof opt.encoding !== "string") {
        opt.encoding = "utf8";
    }

    //Extends the readable stream
    stream.Readable.call(this, {encoding: opt.encoding});

    this._tag = (typeof opt.tag === "string") ? opt.tag.trim() : null;
    this._level = labels.length;
    this._disabled = false;

    //Default message format
    this._format = function (tag, label, text) {
        let list = [];
        if (tag) {
            //Add the tag if it is provided
            list.push("[" + tag + "]");
        }
        list.push("[" + timestamp("YYYY-MM-DD hh:mm:ss") + "]");
        list.push("[" + label.toUpperCase() + "]");
        list.push(text.trim());
        return list.join(" ");
    };

    return this;
}
function (opt) {
    if (typeof opt !== "object" || opt === null) {
        opt = {};
    }
    if (typeof opt.tag !== "string") {
        opt.tag = null;
    }
    if (typeof opt.encoding !== "string") {
        opt.encoding = "utf8";
    }

    //Extends the readable stream
    stream.Readable.call(this, {encoding: opt.encoding});

    this._tag = (typeof opt.tag === "string") ? opt.tag.trim() : null;
    this._level = labels.length;
    this._disabled = false;

    //Default message format
    this._format = function (tag, label, text) {
        let list = [];
        if (tag) {
            //Add the tag if it is provided
            list.push("[" + tag + "]");
        }
        list.push("[" + timestamp("YYYY-MM-DD hh:mm:ss") + "]");
        list.push("[" + label.toUpperCase() + "]");
        list.push(text.trim());
        return list.join(" ");
    };

    return this;
}
function ( opt ) { if ( typeof opt !== "object" || opt === null ) { opt = { } ; } if ( typeof opt . tag !== "string" ) { opt . tag = null ; } if ( typeof opt . encoding !== "string" ) { opt . encoding = "utf8" ; } //Extends the readable stream stream . Readable . call ( this , { encoding : opt . encoding } ) ; this . _tag = ( typeof opt . tag === "string" ) ? opt . tag . trim ( ) : null ; this . _level = labels . length ; this . _disabled = false ; //Default message format this . _format = function ( tag , label , text ) { let list = [ ] ; if ( tag ) { //Add the tag if it is provided list . push ( "[" + tag + "]" ) ; } list . push ( "[" + timestamp ( "YYYY-MM-DD hh:mm:ss" ) + "]" ) ; list . push ( "[" + label . toUpperCase ( ) + "]" ) ; list . push ( text . trim ( ) ) ; return list . join ( " " ) ; } ; return this ; }
Logty readable stream
Logty readable stream