erlang / otp

Erlang/OTP
http://erlang.org
Apache License 2.0
11.18k stars 2.92k forks source link

ERL-1149: Create C functions for sending logs events from NIFs #4061

Open OTP-Maintainer opened 4 years ago

OTP-Maintainer commented 4 years ago

Original reporter: hauleth Affected version: Not Specified Component: Not Specified Migrated from: https://bugs.erlang.org/browse/ERL-1149


This can be useful in some situations where there are used more extensive NIFs like in [Membrane Framework|https://www.membraneframework.org]. Currently it implements such functionality [on their own|https://github.com/membraneframework/membrane-common-c/blob/7bde6530e3740aa1d1cd1a14cece3b8554d78d72/c_src/membrane/log.c], but I think that such functionality would be useful in other NIFs as well.
OTP-Maintainer commented 4 years ago

lukas said:

On issue with doing this is that there is no way to implement flow control for such log messages. The emulator when it has to log things already has to do a very special dance for it to work. When this has been suggested in the past I've always suggested that the logging should be done by yielding back into Erlang and calling logger.
OTP-Maintainer commented 4 years ago

hauleth said:

I understand that this is not easy to have this implemented fully in C, however it would be handy to have something like "gateway" that would handle messages from NIFs. This would probably require adding few functions to the {{erl_nif}} (for example to get data from process dictionary) but IMHO could improve NIFs in situations like this one.