Something like flush function for logger?

I’m building escript and using logger but i have noticed that if my script finishes too fast not all log information is printed (either in terminal or in a log files). Currently i’m working around this problem by invoking timer:sleep/1 and it seems to solve my problem. However sleep time and filesync_repeat_interval for logger_disk_log_h needs to be in agreement which is explicit coupling that i don’t like. Is there any facility like flush that would force logger to output what it has at the moment so that use of sleep could be eliminated?

note: i’m currently not starting my code as application behavior.


i have missed logger_disk_log_h:filesync/1 which also works and removes timer need. However more general logger:sync/0-1 would be also nice.


AFAIK you’ll need either for upstream to add a sync or flush to the API, or you need to break the abstractions and call logger_olp:info(Handle) where Handle is the registered name or Pid of your handler. (That’s assuming you’re using one of the OTP standard handlers.)

I agree that having this as an official part of the API would be desirable.