@@ -17,12 +17,9 @@ export class AlternatingFileWriter {
1717 private readonly _fileSystem : FileSystem ,
1818 private readonly _mainFile : string ,
1919 private readonly _fallbackFile : string ,
20- private readonly _maxLines : number ,
20+ private readonly _maxLines ? : number ,
2121 private readonly _maxSize ?: number ,
2222 ) {
23- if ( this . _maxLines <= 0 ) {
24- throw new Error ( 'File capacity may not be less or equal to 0.' ) ;
25- }
2623 this . _streamWriter = this . _fileSystem . streamWriter ;
2724 }
2825
@@ -72,11 +69,11 @@ export class AlternatingFileWriter {
7269
7370 const logLength = log . length + 1 ;
7471
75- if ( currentCount + 1 > this . _maxLines ) {
72+ if ( currentCount + 1 > ( this . _maxLines ?? Infinity ) ) {
7673 break ;
7774 }
7875
79- if ( this . _maxSize && currentSize + logLength >= this . _maxSize ) {
76+ if ( currentSize + logLength >= ( this . _maxSize ?? Infinity ) ) {
8077 break ;
8178 }
8279
@@ -111,7 +108,7 @@ export class AlternatingFileWriter {
111108 private prepareBreadcrumbStream ( newSize : number ) {
112109 if ( ! this . _streamId ) {
113110 this . _streamId = this . _streamWriter . create ( this . _mainFile ) ;
114- } else if ( this . _count >= this . _maxLines || ( this . _maxSize && this . _size + newSize >= this . _maxSize ) ) {
111+ } else if ( this . _count >= ( this . _maxLines ?? Infinity ) || this . _size + newSize >= ( this . _maxSize ?? Infinity ) ) {
115112 this . switchFile ( ) ;
116113 }
117114 }
0 commit comments