Unfortunately, besides the correct implementation of the "flush" command in the io / kernel subsystem, and making sure that low-level drivers that implement actual iio support, you really need to rely on system quiesing before closing it. It seems that I did not work.
Look at io.erl / io_lib.erl in stdlib and file_io_server.erl / prim_file.erl in the kernel for gory details.
, file_io_server ( io/io_lib ), :
{put_chars,Chars}
{get_until,...}
{get_chars,...}
{get_line,...}
{setopts, ...}
(.. )!
, , ( ) . , , - , ( gen_server , ):
case file:open(LogFile, [append]) of
{ok, IODevice} ->
io:fwrite(IODevice, "~n~2..0B ~2..0B ~4..0B, ~2..0B:~2..0B:~2..0B: ~-8s : ~-20s : ~12w : ",
[Day, Month, Year, Hour, Minute, Second, Priority, Module, Pid]),
io:fwrite(IODevice, Msg, Params),
io:fwrite(IODevice, "~c", [13]),
file:close(IODevice);