Skip to content

Close logger #73

Closed
Closed
@gagle

Description

@gagle

To close all the loggers with a callback completion (similar to the commented one):

Logger.prototype.close = function (cb){
    if (this._closed) return cb ();

    var me = this;
    var remaining = this.streams.length;
    if (!remaining) return cb ();

    this.streams.forEach (function (s){
        s.stream.stream.on ("close", function (){
            if (!--remaining && cb) cb ();
        });
        s.stream.stream.end ();
    });

    this._closed = true;
};

EDIT: this code only works when the file type is "rotation-file". If it's the normal file then s.stream.end() and s.stream.on("close") should be used.

Not tested with childs. Sorry for all the posted issues but this module needs to be revisited.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions