File tree Expand file tree Collapse file tree 3 files changed +16
-4
lines changed Expand file tree Collapse file tree 3 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ Yii Framework 2 Change Log
442.0.50 under development
55------------------------
66
7- - no changes in this release.
7+ - Bug # 19940 : File Log writer without newline (terabytesoftw)
88
99
10102.0.49 August 29, 2023
Original file line number Diff line number Diff line change @@ -130,12 +130,12 @@ public function export()
130130 if ($ this ->enableRotation && @filesize ($ this ->logFile ) > $ this ->maxFileSize * 1024 ) {
131131 $ this ->rotateFiles ();
132132 }
133- $ writeResult = @fwrite ($ fp , $ trimmedText );
133+ $ writeResult = @fwrite ($ fp , $ text );
134134 if ($ writeResult === false ) {
135135 $ error = error_get_last ();
136136 throw new LogRuntimeException ("Unable to export log through file ( {$ this ->logFile })!: {$ error ['message ' ]}" );
137137 }
138- $ textSize = strlen ($ trimmedText );
138+ $ textSize = strlen ($ text );
139139 if ($ writeResult < $ textSize ) {
140140 throw new LogRuntimeException ("Unable to export whole log through file ( {$ this ->logFile })! Wrote $ writeResult out of $ textSize bytes. " );
141141 }
Original file line number Diff line number Diff line change @@ -123,7 +123,19 @@ public function testLogEmptyStrings()
123123 $ logger ->export ();
124124
125125 $ test = file ($ logFile );
126- $ this ->assertEquals ("xxx " , $ test [0 ]);
126+ $ this ->assertEquals ("xxx \n" , $ test [0 ]);
127+
128+ $ this ->clearLogFile ($ logFile );
129+
130+ $ logger = new CustomLogger ();
131+ $ logger ->logFile = $ logFile ;
132+ $ logger ->messages = array_fill (0 , 3 , 'xxx ' );
133+ $ logger ->export ();
134+
135+ $ test = file ($ logFile );
136+ $ this ->assertEquals ("xxx \n" , $ test [0 ]);
137+ $ this ->assertEquals ("xxx \n" , $ test [1 ]);
138+ $ this ->assertEquals ("xxx \n" , $ test [2 ]);
127139
128140 $ this ->clearLogFile ($ logFile );
129141
You can’t perform that action at this time.
0 commit comments