lib/transports/file.js
function createAndFlush(size) {
            if (self._stream) {
                self._stream.end();
                self._stream.destroySoon();
            }

            self._size = size;
            self.filename = target;
            self._stream = fs.createWriteStream(fullname, self.options);

            //
            // We need to listen for drain events when
            // write() returns false. This can make node
            // mad at times.
            //
            self._stream.setMaxListeners(Infinity);

            //
            // When the current stream has finished flushing
            // then we can be sure we have finished opening
            // and thus can emit the `open` event.
            //
            self.once('flush', function () {
                // Because "flush" event is based on native stream "drain" event,
                // logs could be written inbetween "self.flush()" and here
                // Therefore, we need to flush again to make sure everything is flushed
                self.flush();

                self.opening = false;
                self.emit('open', fullname);
            });

            //
            // Remark: It is possible that in the time it has taken to find the
            // next logfile to be written more data than `maxsize` has been buffered,
            // but for sensible limits (10s - 100s of MB) this seems unlikely in less
            // than one second.
            //
            self.flush();
        }
function createAndFlush(size) {
            if (self._stream) {
                self._stream.end();
                self._stream.destroySoon();
            }

            self._size = size;
            self.filename = target;
            self._stream = fs.createWriteStream(fullname, self.options);

            //
            // We need to listen for drain events when
            // write() returns false. This can make node
            // mad at times.
            //
            self._stream.setMaxListeners(Infinity);

            //
            // When the current stream has finished flushing
            // then we can be sure we have finished opening
            // and thus can emit the `open` event.
            //
            self.once('flush', function () {
                // Because "flush" event is based on native stream "drain" event,
                // logs could be written inbetween "self.flush()" and here
                // Therefore, we need to flush again to make sure everything is flushed
                self.flush();

                self.opening = false;
                self.emit('open', fullname);
            });

            //
            // Remark: It is possible that in the time it has taken to find the
            // next logfile to be written more data than `maxsize` has been buffered,
            // but for sensible limits (10s - 100s of MB) this seems unlikely in less
            // than one second.
            //
            self.flush();
        }
function createAndFlush ( size ) { if ( self . _stream ) { self . _stream . end ( ) ; self . _stream . destroySoon ( ) ; } self . _size = size ; self . filename = target ; self . _stream = fs . createWriteStream ( fullname , self . options ) ; // // We need to listen for drain events when // write() returns false. This can make node // mad at times. // self . _stream . setMaxListeners ( Infinity ) ; // // When the current stream has finished flushing // then we can be sure we have finished opening // and thus can emit the `open` event. // self . once ( 'flush' , function ( ) { // Because "flush" event is based on native stream "drain" event, // logs could be written inbetween "self.flush()" and here // Therefore, we need to flush again to make sure everything is flushed self . flush ( ) ; self . opening = false ; self . emit ( 'open' , fullname ) ; } ) ; // // Remark: It is possible that in the time it has taken to find the // next logfile to be written more data than `maxsize` has been buffered, // but for sensible limits (10s - 100s of MB) this seems unlikely in less // than one second. // self . flush ( ) ; }
Creates the `WriteStream` and then flushes any buffered messages.
Creates the WriteStream and then flushes any buffered messages .