Skip to content

Commit 24d15f3

Browse files
committed
Add manual flush on Octave in mp.logger.printf() after each write to log file.
1 parent 983bcf6 commit 24d15f3

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

lib/+mp/logger.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
% * fid - file ID returned by ``fopen()``
1313
% * log_file_path - path to log file
1414
% * write_to_console - writes to both console **and** file, if true
15+
% * manual_flush - true by default on Octave, requiring fflush()
1516
%
1617
% mp.logger Methods:
1718
% * logger - constructor
@@ -36,6 +37,7 @@
3637
fid % file ID returned by ``fopen()``
3738
log_file_path % path to log file
3839
write_to_console % writes to both console **and** file, if true
40+
manual_flush=false; % true by default on Octave, requiring fflush()
3941
end %% properties
4042

4143
methods
@@ -77,6 +79,9 @@
7779
% write_to_console (logical) : *(default = 0)* writes to both
7880
% console **and** file, if true
7981

82+
if have_feature('octave')
83+
obj.manual_flush = true;
84+
end
8085
obj.set_file(varargin{:});
8186
end
8287

@@ -146,6 +151,9 @@
146151
else %% use our fid, instead of 1 or 2
147152
fprintf(obj.fid, varargin{2:end});
148153
end
154+
if obj.manual_flush
155+
fflush(obj.fid);
156+
end
149157
if obj.write_to_console
150158
fprintf(varargin{:});
151159
end

0 commit comments

Comments
 (0)