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
4
4
2.0.50 under development
5
5
------------------------
6
6
7
- - no changes in this release.
7
+ - Bug # 19940 : File Log writer without newline (terabytesoftw)
8
8
9
9
10
10
2.0.49 August 29, 2023
Original file line number Diff line number Diff line change @@ -130,12 +130,12 @@ public function export()
130
130
if ($ this ->enableRotation && @filesize ($ this ->logFile ) > $ this ->maxFileSize * 1024 ) {
131
131
$ this ->rotateFiles ();
132
132
}
133
- $ writeResult = @fwrite ($ fp , $ trimmedText );
133
+ $ writeResult = @fwrite ($ fp , $ text );
134
134
if ($ writeResult === false ) {
135
135
$ error = error_get_last ();
136
136
throw new LogRuntimeException ("Unable to export log through file ( {$ this ->logFile })!: {$ error ['message ' ]}" );
137
137
}
138
- $ textSize = strlen ($ trimmedText );
138
+ $ textSize = strlen ($ text );
139
139
if ($ writeResult < $ textSize ) {
140
140
throw new LogRuntimeException ("Unable to export whole log through file ( {$ this ->logFile })! Wrote $ writeResult out of $ textSize bytes. " );
141
141
}
Original file line number Diff line number Diff line change @@ -123,7 +123,19 @@ public function testLogEmptyStrings()
123
123
$ logger ->export ();
124
124
125
125
$ 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 ]);
127
139
128
140
$ this ->clearLogFile ($ logFile );
129
141
You can’t perform that action at this time.
0 commit comments